微信小程序访问豆瓣电影api400错误解决方法
uni.request({
url:'https://api.douban.com/v2/movie/coming_soon?apikey=0b2bdeda43b5688921839c8ecb20399b',
method: 'GET',
data:{},
header:{
"Content-Type":""application/json""
},
success: (res) => {
// console.log('进入res');
// console.log(res.data);
this.list[0]=res.data.subjects;
this.listUrl=this.listUrl.concat('https://api.douban.com/v2/movie/coming_soon');
}});`
原来是开发工具升级后,请求的header的Content-type写法变了(我现在使用的开发工具版本为0.11),需要改为
header:{
"Content-Type":"json"
},
这样就可以正常请求了
转载于:https://www.cnblogs.com/bubbleStar/p/6103350.html