Hello ! I am developing a React application and I am trying to integrate it with your public API (https://api.getsling.com/v1/). My application is currently running on http://localhost:3000 during development.
To interact with your API, I need to make cross-origin requests from my frontend. However, when I try to do this, I encounter the following error: "Request origin did not match allowed origins"
This error suggests that my application's origin is not authorized to make requests to your API, which is likely due to CORS (Cross-Origin Resource Sharing) restrictions. Here is an example of the code I am using:
const apiUrl = 'https://api.getsling.com/v1/users';
const fetchUsers = async () => {
try {
const response = await fetch(apiUrl, {
method: 'GET',
headers: {
'Authorization': 'Bearer 85c1aad28ac4437c9c4f0e6c4b0f2810',
'Accept': 'application/json',
},
});
if (response.ok) {
const users = await response.json();
console.log('Users:', users);
} else {
console.error('Failed to fetch users:', response.status, response.statusText);
}
} catch (error) {
console.error('Error:', error);
}
};
Any advice or documentation you could provide would be greatly appreciated.
Thank you for your support!