I'm doing a POST
request from my frontend using fetch
API. But when I tried in Firefox, it doesn't work. In Chrome works fine.
Here's what I'm trying to do.
const handleSubmit = async event => {
try {
await fetch(`https://api.example.net/api/route?slug=example`, {
method: 'post',
headers: {
'Content-Type': 'application/json',
'x-api-key': /* API KEY*/
},
body: JSON.stringify({
name,
email
})
})
.then(response => console.log(response))
.catch(err => console.log(err));
} catch (error) {
console.log(error);
}
};