小程序开发二三事--数据请求head的设置

wx.request(OBJECT)

发起请求的方法有很多,默认为 GET,有效值:OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT;

一般在项目开发中用得较多的就是GET 和 POST

在发起请求时,header 要设置正确:

get请求时为

header:{
            "content-type":'application/json'
        },

post请求时为:

 header:{
        "content-type":'application/x-www-form-urlencoded'
    }

注意: POST时必须要设置
"content-type":'application/x-www-form-urlencoded',否则,请求不成功!
原文地址:https://www.cnblogs.com/garfieldzhong/p/6755452.html