标签:相关 OLE 使用 封装 pos targe res ref develop
后端同事提供的接口是get请求,需要通过body传值,在postman里面是可以正常请求的,但是使用axios的时候却参数总是不正确。
后来查了相关文档,get请求是没有请求主体的,axios封装的get请求也不会把主体(body)传给后端,如果需要传递主体的话,就得post请求或者其他。
改成post请求就可以正常请求后端数据了。
let config = {
method: ‘post‘,
url: ‘https://example.com/home‘,
data: [1, 2]
};
axios(config)
.then(function (response) {
console.log(response)
})
.catch(function (error) {
console.log(error)
});
参考链接:
https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Methods/GET
标签:相关 OLE 使用 封装 pos targe res ref develop
原文地址:https://www.cnblogs.com/roland-sky/p/14738827.html