繁体   English   中英

axios 的问题得到错误 400 错误请求

[英]problem with axios get error 400 bad request

我已经卡住了很长一段时间,因为当我调用我的 API 来检索数据(因此是 GET 方法)时,我在 postman 上关闭了 400 错误请求错误,我设法检索状态为 200 的数据。但是在我的 Z3DB28C3787D79339我传递参数以及有用的标题。

代码 axios 状态 400:

 async getAssociatedPlant() { this.$axios.$get('lnk/plant/plants', { headers: { "Content-Type": "application/json", }, params: { link: "good", plant_id: this.plantActive.id, }, }).then(response => { console.log(response) }).catch(error => { console.log(error) }); },

有助于理解的图像:

Postman 标题状态 200 OK

Postman 参数状态 200 OK

Erreur 400 错误请求

请求有效载荷

请求响应

尝试将 data:{} 添加到您的请求配置中。

async getAssociatedPlant() {
    this.$axios.$get('lnk/plant/plants', {
        headers: {
            "Content-Type": "application/json",
        },
        data:{},
        params: {
            link: "good",
            plant_id: this.plantActive.id,
        },

    })
        .then(response => {
            console.log(response)
        }).catch(error => {
            console.log(error)
        });
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM