Hi there I'm using google cloud function as a middleware for my POST CALL, and I'm getting this error
Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
The code in google cloud function is
exports.helloWorld = (req, res) => {
res.set("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Credentials", "true");
res.setHeader("Access-Control-Allow-Methods", "GET,HEAD,OPTIONS,POST,PUT");
res.setHeader("Access-Control-Allow-Headers", "Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Access-Control-Request-Headers");
res.send({id: req.body.data._id, key: req.body.data._key, qty: req.body.data.quantity})
}
I'm just trying to get the _id, _key and quantity,
This is how I make the call
axios.post("url", {_id,_key,quantity}, {headers: {
'Content-Type' : 'application/json; charset=UTF-8'
}}).then(res => console.log(res, 'res ')) .catch(err => console.log(err,"err"));