I am trying to pull API data and when I do, I get the error message of "No Access Control Origin detected" even though I add a Access Control Allow Origin header
When I npm start in Chrome/Firefox it doesn't work but when I use IE it does work
Here is my code:
componentDidMount() {
fetch(url , {
mode: 'cors',
headers: {
'X-API-KEY': API_KEY,
'Access-Control-Allow-Origin': 'https://localhost:3000/',
'Access-Control-Allow-Credentials': 'true',
'Access-Control-Allow-Headers': 'Content-Type, Origin, Accept, Authorization',
'Accept': 'application/json',
'Content-Type': 'application/json'
}
})
.then(res => res.json())
.then(json => {
this.setState({
isLoaded: true,
items: json,
})
})
};