微信小程序访问豆瓣电影api400错误解决方法

2016-12-27  本文已影响62人  winning_

wx.request({
url : "https://api.douban.com/v2/movie/in_theaters",
data: {},
header:{
"Content-Type":"application/json"
},
success: function(res) {
console.log(res.data);
var data = res.data;
currentPage.setData({
list : data.subjects
})
},
});

原来是开发工具升级后,请求的header的Content-type写法变了(我现在使用的开发工具版本为0.11),需要改为

header:{
"Content-Type":"json"
},
上一篇下一篇

猜你喜欢

热点阅读