最近在跟着demo学习微信小程序,却卡在了第一步请求豆瓣电影api上,折腾了很久,代码如下:

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
        })
    },
});    

 

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

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

header:{
    "Content-Type":"json"
},

这样就可以正常请求了

相关文章:

  • 2022-01-01
  • 2022-01-04
  • 2021-12-11
  • 2022-01-01
  • 2021-08-14
  • 2021-12-03
  • 2022-01-01
猜你喜欢
  • 2021-12-11
  • 2021-11-06
  • 2022-01-01
  • 2021-05-17
  • 2021-07-12
  • 2022-12-23
  • 2022-01-01
相关资源
相似解决方案