小程序发起网络请求报错request:fail url not in domain list

使用如下方法进行网络请求走失败回调,报错request:fail url not in domain list
wx.request({
  url: 'https://www.jianshu.com/writer#/notebooks/42553100/notes/60066881/preview',
  header: {
    'content-type': 'application/json' // 默认值
  },
   success: function(res){  
    console.log(res.data)
    } ,
    fail:function(res){
      console.log(res.data)
    }
   })

解决方法如下:开发阶段必须把红色方框中的配置勾选上,否则url请求无效。

image.png

你可能感兴趣的:(小程序发起网络请求报错request:fail url not in domain list)