在线不卡日本ⅴ一区v二区_精品一区二区中文字幕_天堂v在线视频_亚洲五月天婷婷中文网站

  • <menu id="lky3g"></menu>
  • <style id="lky3g"></style>
    <pre id="lky3g"><tt id="lky3g"></tt></pre>

    jquery axios go的Post請(qǐng)求 自定義header

    jquery

    var settings = { “url”: “http://127.0.0.1/”, “method”: “POST”, “timeout”: 0, “headers”: { “token”: “xxx123”, “Content-Type”: “application/x-www-form-urlencoded” }, “data”: { “username”: “zhangsan”, “password”: “123456” }};$.ajax(settings).done(function (response) { console.log(response);});

    axios

    var axios = require(‘axios’);var qs = require(‘qs’);var data = qs.stringify({ ‘username’: ‘zhangsan’, ‘password’: ‘123456’ });var config = { method: ‘post’, url: ‘http://127.0.0.1/’, headers: { ‘token’: ‘xxx123’, ‘Content-Type’: ‘application/x-www-form-urlencoded’ }, data : data};axios(config).then(function (response) { console.log(JSON.stringify(response.data));}).catch(function (error) { console.log(error);});

    go

    package mainimport ( “fmt” “strings” “net/http” “io/ioutil”)func main() { url := “http://127.0.0.1/” method := “POST” payload := strings.NewReader(“username=zhangsan&password=123456”) client := &http.Client { } req, err := http.NewRequest(method, url, payload) if err != nil { fmt.Println(err) return } req.Header.Add(“token”, “xxx123”) req.Header.Add(“Content-Type”, “application/x-www-form-urlencoded”) res, err := client.Do(req) if err != nil { fmt.Println(err) return } defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } fmt.Println(string(body))}

    鄭重聲明:本文內(nèi)容及圖片均整理自互聯(lián)網(wǎng),不代表本站立場(chǎng),版權(quán)歸原作者所有,如有侵權(quán)請(qǐng)聯(lián)系管理員(admin#wlmqw.com)刪除。
    上一篇 2022年7月31日 17:52
    下一篇 2022年7月31日 17:52

    相關(guān)推薦

    聯(lián)系我們

    聯(lián)系郵箱:admin#wlmqw.com
    工作時(shí)間:周一至周五,10:30-18:30,節(jié)假日休息