微信小程序wx.request的header疑问

我自己测试微信小程序的wx.request功能。

header设置 'Content-Type': 'json' 能获取到结果

wx.request({
  url: 'https://api.douban.com/v2/movie/in_theaters',
  method: 'GET',
  header: {
    'Content-Type': 'json' // 使用这个能正常获取数据
  },
  success: function(res) {
    console.log(res);
  }
})

图片描述


header设置 'Content-Type': 'application/json' 不能获取结果

wx.request({
  url: 'https://api.douban.com/v2/movie/in_theaters',
  method: 'GET',
  header: {
    'Content-Type': 'application/json'// 使用这个不能获取数据
  },
  success: function(res) {
    console.log(res);
  }
})

图片描述

这两种写法到底有什么不同?为什么会导致这种问题产生?
'Content-Type': 'json'
'Content-Type': 'application/json'

阅读 14.2k
1 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题