let req = {
siteid: 0,
bid: 209291,
cid: 1
}
await requestPostFn('http://www.doupocangqiong.info/novelsearch/chapter/transcode.html', req)
async function requestPostFn(url, data) {
const res = await uniCloud.httpclient.request(url, {
method: 'POST',
headers: {
'content-type': 'application/x-www-form-urlencoded',
},
timeout: 60000,
content:`siteid=${data.siteid}&bid=${data.bid}&cid=${data.cid}`,
dataType: 'json',
followRedirect: true, //如果返回301或3XX后开启自动重定向
// nestedQuerystring:true,
})
console.log(res)
return res.data
}
李钊
- 发布:2023-07-14 16:04
- 更新:2023-07-14 16:52
- 阅读:280
【报Bug】云函数发送http请求时使用POST请求content-type为application/x-www-form-urlencoded时报错500,在postMan上请求是成功的
分类:uniCloud
产品分类: uniCloud/App
示例代码:
操作步骤:
请求报错500
请求报错500
预期结果:
请求成功200
请求成功200
实际结果:
请求报错500
请求报错500
bug描述:
let req = {
siteid: 0,
bid: 209291,
cid: 1
}
await requestPostFn('http://www.doupocangqiong.info/novelsearch/chapter/transcode.html', req)
async function requestPostFn(url, data) {
const res = await uniCloud.httpclient.request(url, {
method: 'POST',
headers: {
'content-type': 'application/x-www-form-urlencoded',
},
timeout: 60000,
content:`siteid=${data.siteid}&bid=${data.bid}&cid=${data.cid}`,
dataType: 'json',
followRedirect: true, //如果返回301或3XX后开启自动重定向
// nestedQuerystring:true,
})
console.log(res)
return res.data
}