yangbo5207 / everyday

Something I learn every day.
5 stars 0 forks source link

小程序: 接口请求中遇到的问题 #63

Open yangbo5207 opened 7 years ago

yangbo5207 commented 7 years ago
  1. 需要手动转码 encodeURIComponent

  2. 需要在header中设置charset=UTF-8

  3. 需要在header中设置content-type为接口中需要的类型

promise(wx.request)({
    url: `${config.communityDomainDev}/v5/comment`,
    method: 'POST',
    data: {
        objectId: postid,
        type: type,
        content: encodeURIComponent(_this.data.inputValue)
    },
    header: { 
        Authorization: authorization,
        'content-type': 'application/x-www-form-urlencoded;charset=UTF-8'
    }
})