提交 acd7e645 编写于 作者: 雪洛's avatar 雪洛

fix: 钉钉小程序content-type为application/json时自动序列化data

上级 9a8f2446
......@@ -89,19 +89,32 @@ const protocols = { // 需要做转换的 API 列表
if (!fromArgs.header) { // 默认增加 header 参数,方便格式化 content-type
fromArgs.header = {}
}
const headers = {
'content-type': 'application/json'
}
Object.keys(fromArgs.header).forEach(key => {
headers[key.toLocaleLowerCase()] = fromArgs.header[key]
})
return {
header (header = {}, toArgs) {
const headers = {
'content-type': 'application/json'
}
Object.keys(header).forEach(key => {
headers[key.toLocaleLowerCase()] = header[key]
})
return {
name: 'headers',
value: headers
}
},
data (data) {
// 钉钉在content-type为application/json时,不会自动序列化
if (my.dd && headers['content-type'].indexOf('application/json') === 0) {
return {
name: 'data',
value: JSON.stringify(data)
}
}
return {
name: 'data',
value: data
}
},
method: 'method', // TODO 支付宝小程序仅支持 get,post
responseType: false
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册