【发布时间】:2020-12-26 18:27:45
【问题描述】:
我有一个使用 Nuxt.js 构建的应用程序。为了从 API 获取数据,我使用 axios,即@nuxtjs/axios。除了 DELETE 方法之外,所有请求都可以正常工作。
我的语法如下:
async removeItemFromCart(productId) {
const accessKey = await this.$store.dispatch('fetchUserAccessKey');
try {
this.$axios.delete(`/api/baskets/products?userAccessKey=${ accessKey }`, {
data: {
productId: productId
}
})
} catch (error) {
console.log(error);
}
},
但是,在控制台中我总是收到以下错误:createError.js?2d83:16 Uncaught (in promise) Error: Request failed with status code 400
我尝试使用参数而不是数据,但无济于事。我在这里错过了什么?
【问题讨论】: