1

🚩 http传参方式

header、query、body
1⃣️ header
 Request Headers
 cookie: xxx
2⃣️ query
url?id=1
3⃣️ body
request payload

🚩 axios

1⃣️ 头部传参
axios.post(url, data, {
    headers: {
        'token': token
        }
    }).then(function(response) {
       console.log(response)
    });
2⃣️ axios#get(url[, config])
// url?id=1
axios.get(url,{
    params: {
      id: 1
    }
}).then(function (response) {
    console.log(response);
})
3⃣️ axios#post(url[, data[, config]])
// request payload {id:1}
axios.post(url, {
    id: 1
}).then(function (response) {
    console.log(response);
})
4⃣️ axios#delete(url[, config])
// url?id=1
axios.delete(url, {
    params: {
        id: 1
    }
}).then(function (response) {
    console.log(response);
})


// request payload {id:1}
axios.delete('url', params = {
    data: {
        id: 1
    }
}).then(function (response) {
    console.log(response);
})
5⃣️ axios#put(url[, config])
// url?name='yumi'
// request payload {id:1}
axios.put('url', {
      id: 1
    }, {
      params: {
        name: 'yumi'
      }
}).then(function (response) {
    console.log(response);
})

yumi55
2 声望0 粉丝