I'm using Axios library to make an API call in my React application.I call the API and then populate a table using React.
My Axios call is as follows:
axios({
method: 'get',
url: DataURL,
headers: {
'Content-Type' : 'application/json',
'Id': user.Id,
'Name' : user.Name,
'api-token' : user.access_token,
'clientId' : 'web',
},
responseType: 'json',
})
.then((response) => {
this.setState({ tableData: response.data });
});
However I get this error:
XMLHttpRequest cannot load MY API URL Response for preflight has invalid HTTP status code 400
The same was working in my dev environment where I wasn't adding any headers, however after migrating to new env which required me to add headers, Im getting the above error. My question is, is this a client side issue(like wrong header format etc) or is it something to do with server side handling of the API call?