uni-app uniCloud.httpProxyForEip.postJson请求微信接口无法成功
uni-app uniCloud.httpProxyForEip.postJson请求微信接口无法成功
示例代码:
// 能成功
const code = await uniCloud.httpclient.request(`https://api.weixin.qq.com/wxa/getversioninfo?access_token=${token.data[0].authorizer_access_token}`, {
method: 'POST',
dataType: 'json',
data: JSON.stringify({}),
timeout: 10000
})
console.log(code, 'code111111')
不成功
const code2 = await uniCloud.httpProxyForEip.postForm(
`https://api.weixin.qq.com/wxa/getversioninfo?access_token=${token.data[0].authorizer_access_token}`,
'{}',
{
'Content-Type': 'application/json'
}
)
console.log(code2, 'codea222222')
操作步骤:
.
预期结果:
.
实际结果:
.
bug描述:
腾讯开放平台接口需要固定ip请求,查询官网使用uniCloud.httpProxyForEip.postForm
但是发现uniCloud.httpProxyForEip.postForm并不能实现腾讯接口的要求,接口要求post并且要传空的json,不传会报错,尝试很多都无效!
正确使用能调通的方式:
const code = await uniCloud.httpclient.request(`https://api.weixin.qq.com/wxa/getversioninfoaccess_token=${token.data[0].authorizer_access_token}`, {
method: 'POST',
dataType: 'json',
data: JSON.stringify({}),
timeout: 10000
})
这样是可以使用的,但是因为固定ip经常需要去绑定ip,现在需要使用uniCloud.httpProxyForEip.postForm
发现uniCloud.httpProxyForEip.postForm并不能请求成功
const code2 = await uniCloud.httpProxyForEip.postForm(
`https://api.weixin.qq.com/wxa/getversioninfo?access_token=${token.data[0].authorizer_access_token}`,
{},
{
'Content-Type': 'application/json'
}
)
不管把参数换成 {} 或者 { data:JSON.stringify({}) }, 或者直接’{}’ 都不行,对方要求传空的json,下面是图
更多关于uni-app uniCloud.httpProxyForEip.postJson请求微信接口无法成功的实战教程也可以访问 https://www.itying.com/category-93-b0.html
1 回复
更多关于uni-app uniCloud.httpProxyForEip.postJson请求微信接口无法成功的实战教程也可以访问 https://www.itying.com/category-93-b0.html
试一下uniCloud.httpProxyForEip.postAPI