I used Axios for API, here is my code. I am getting CROS error.
JavaScript
x
12
12
1
axios({
2
method: 'GET',
3
headers : { 'Content-Type': 'application/json',
4
'Access-Control-Allow-Origin' : '*',
5
'mode': 'cors',
6
'Authorization':'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1N....'
7
},
8
url: baseURL,
9
}).then(function (response) {
10
console.log(response);
11
});
12
Advertisement
Answer
You’ll need to enable CORS from your back-end service. From the image, it is clear that your front-end in running on localhost on port 3000 whereas your back-end or api service is running on port 8000 on localhost. So, enable CORS from your back-end or api serivce.