Reputation: 1
I am getting error
Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
first = async () => {
const data = {
firstName:'abcdef',lastName:'defghi'
};
const resp = await axios({
method:'post',
url: 'url here' ,
data,
}
);
console.log(resp);
I can only change in front-end code. Any help would be appreciated?
Upvotes: 0
Views: 131
Reputation: 690
It seems that needs client request headers:
first = async () => {
const data = {
firstName:'abcdef',lastName:'defghi'
};
const resp = await axios({
method:'post',
url: 'url here' ,
data: data,
headers: {
'Allow-control-allow-origin': 'domain permitted here',
'Authorization': 'authorization here'
//eg: 'Aurhorization': 'Basic: ' + window.btoa(generatedCredentials);
}
}
);
console.log(resp);
Upvotes: 1