I am trying to hit the login API with Custom header. First I got CORS error:
Access to XMLHttpRequest at 'URL' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource
Then I disabled CORS by NO CORS Plugin. Now Im getting:
Access to XMLHttpRequest at 'URL' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
Below is my code:
const userDetails = { email, password };
let data = JSON.stringify({
request : {
ascUser :
{
userName : "[email protected]",
password : "12345678"
}
}
})
return dispatch => {
axios.request('URL', {data:data},
{headers: {
'Content-Type': 'application/json',
'x-transId' : '****',
'x-channel-id' : '***'
}}
)
.then(res => res.json())
.then(res => {
console.log(res)
if(res.error) {
throw(res.error);
}
dispatch(
userLogin({
...userDetails
})
);
return res.products;
})
.catch(error => {
console.log(error)
}
)
};
}```