I am having some problems with fetching data from database written in Python (it works when I try it using POSTMAN / INSOMIA). The code which I included to React component (client side) is:
axios.get('http://192.168.8.103:8000/messenger_api/fb_fanpages/', {
withCredentials: true,
headers: {
'authorization': 'Token 53983',
'content-type': 'application/json'
}
}).then(resp => {
console.log(resp)
}).catch(err => {
console.log(err)
})
and the output which I recieve is
XMLHttpRequest cannot load http://192.168.8.103:8000/messenger_api/fb_fanpages/.
Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://localhost:3000' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
Another thing which is worth mentioning is that when I try to fetch data from starwars api doing this bit of code
axios.get('http://swapi.co/api/people').then((resp) => {
console.log(resp)
}).catch(err => {
console.log(err)
})
It works ok…
Any help will be highly appreciated.