Taí*_*tas 4 javascript firefox reactjs fetch-api next.js
我正在POST使用 API 从前端发出请求fetch。但当我在 Firefox 中尝试时,它不起作用。在 Chrome 中工作正常。
这就是我正在尝试做的事情。
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);
}
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15483 次 |
| 最近记录: |