PC端小程序,请求头带cookie的数据请求??请求失败?
发布于 6 年前 作者 xiangming 13543 次浏览 来自 官方Issues

你好,

情况是:原本小程序里有部分请求是登录后,保存本地cookie,设置请求头带cookie,再去请求数据。

现在pc端的小程序版,请求失败了?

这是为啥呢?

request:fail request faild.

2 回复

请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

userData() {
    let memberUrl = app.globalData.URL + '/member';
    wx.request({
      url: memberUrl,
      data: {},
      header: {
        'content-type': 'application/json',
        'Accept': 'application/json',
        'cookie': wx.getStorageSync("sessionid")
      },
      method: 'GET',
      dataType: 'json',
      responseType: 'text',
      success: (result) => {
        if (result.data.RetCode == "Success") {
          app.globalData.CQuserObj = result.data
        } else {
          wx.reLaunch({
            url: '/pages/Login/Login',
          });
        }
      }
    });
  },

就这样一个请求,手机端是OK的,pc端会请求失败?

回到顶部