i am trying to access data from an api but i got this error
Access to XMLHttpRequest at 'http://example.com/api/login' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
this is my code
return axios.post('http://example.com/api/login', { username: username, password: password }).then(response => {
console.log('response', response);
if (response.status === 400 || response.status === 500)
throw response.data;
return response.data;
}).catch(err => {
console.log('err', err);
throw err[1];
});
Backend built with asp.net
Thank you