微信小程序发送网络请求无法修改请求头?
微信小程序发送网络请求无法修改请求头. // 请求方法
var method = "POST";
// 请求头
var headers = {
"X-Source": source,
"X-Date": datetime,
"Authorization": auth,
}
// 查询参数
var queryParams = {}
// body参数(POST方法下)
var bodyParams = {
"keyword": "Jeep牧马人"
}
// url参数拼接
var url = "https://service-6adxu9k3-1305308687.sh.apigw.tencentcs.com/release/vehicle/query/keyword";
if (Object.keys(queryParams).length > 0) {
url += '?' + querystring.stringify(queryParams);
}
var options = {
url: url,
timeout: 5000,
method: method,
headers: headers
}
if (['POST', 'PUT', 'PATCH'].indexOf(method) != -1) {
options['body'] = querystring.stringify(bodyParams);
options['headers']['Content-Type'] = "application/x-www-form-urlencoded";
}
wx.request({
...options,
success: (res) => {
console.log("getBaseInfoByName res", res)
const {result} = res.data
this.setData({
item: {
...this.data.item,
...result
}
})
wx.hideLoading()
},
fail: (err) => {
console.log("err", err)
wx.hideLoading()
}
})
[图片] api返回的请求头中是没有的