【发布时间】:2021-12-07 03:43:09
【问题描述】:
我正在尝试通过 axios 向我的 api 发送删除和放置请求。 使用 post/get 一切正常,当我尝试使用邮递员发送 delete/put 时,一切都很好,所以问题出在 react 应用程序上。
axios 实例:
const api = Axios.create({
baseURL: "http://localhost:8000",
timeout: 1000,
headers: {'Content-Type': 'application/json'}
});
请求:
Axios.delete("/",{index:name})
.then((response)=>{console.log(response)})
.catch((err)=>{console.log(err)});
*put是一样的,用另一个数据
每当我部署这些代码时,我都会在控制台中收到 404 错误,并且服务器没有收到请求。
【问题讨论】: