'Getting CORS error while logout from OneLogin

I am using the below example link for logout from OneLogin.

https://developers.onelogin.com/api-docs/1/users/log-user-out

I have implemented the below code in my project but I am getting a cors error in the response.

 var data = null;
 var xhr = new XMLHttpRequest(); 
     xhr.withCredentials = true;  
 var url = "https://<subdomain>/api/1/users/<user_id>/logout"; 
     xhr.open("PUT", url); 
     xhr.setRequestHeader("Authorization", "bearer: <access_token>");
     xhr.send(data); 


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source