uni.request实现网页通过code获取access_token openid失败
const requestTask = uni.request({
url: 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=myappid&secret=mysecret&code=mycode&grant_type=authorization_code',
method:'GET',
success: function(res) {
console.log(res.data);
_this.obj2=res.data;
//console.log(res.data.json.name);
},
fail(err){
_this.obj2=err
console.log(err)
},
complete(res) {
console.log(res);//请求完成
}
});
一直失败
get的多个参数 直接在浏览器访问 腾讯能正常返回结果
代码uni.request 访问其他地址也能正常反馈结果
但uni.request 访问腾讯oauth2地址 始终失败,此处是否是bug问题,大咖帮忙解答 如果无解是否有其他解决方案
呆狗的一生
发个demo,我给你看看
2022-06-29 16:01
呆狗的一生
加上contentType:
json
, dataType:json
试试2022-06-29 16:05