javascript - Response for preflight has invalid HTTP status code 400 using Axios -


i'm using axios library make api call in react application.i call api , populate table using react.

my axios call 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 error:

xmlhttprequest cannot load my api url response preflight has invalid http status code 400

the same working in dev environment wasn't adding headers, after migrating new env required me add headers, im getting above error. question is, client side issue(like wrong header format etc) or server side handling of api call?

i think server-side issue. if using node in background need cors middleware (https://www.npmjs.com/package/cors). other server solutions there of course cors request handler.


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -