微信小程序访问豆瓣电影api 400 (Bad Request)错误解决方法

xiaoxiao2021-02-28  94

wx.request({ url: 'http://api.douban.com/v2/movie/in_theaters', data: {}, header: { "Content-Type": "application/json" }, success: function (res) { // console.log(res.data.subjects); // 看开发者api,一定要看清楚给的信息 _this.setData({ list: res.data.subjects }); } })

出现下面的报错

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

header:{ "Content-Type":"json" }, 这样就可以正常访问了;

转载请注明原文地址: https://www.6miu.com/read-84110.html

最新回复(0)