JavaScript:Axios Post请求不发送cookie(HTTP cookie)

时间:2020-07-27 05:01:22

标签: javascript cookies axios setcookie

即使使用“ withCredentials:true”,Axios也不会在我的帖子请求中发送我的cookie。总是收到一条错误消息,提示缺少cookie“ xxx”。甚至尝试过“ axios.defaults.withCredentials = true”,而且看来http cookie是不会发送的。

axios.post('https://www.walmart.com/api/checkout/v3/contract?page=CHECKOUT_VIEW', 
{
    'affiliateInfo:com.wm.reflector': com,
    'city': "example",
    'crt:CRT': "", //this is a cookie that won't send
    'customerId:CID': "",//this is a cookie that won't send
    'customerType:type': "",//this is a cookie that won't send
    'isZipLocated': true,
    'postalCode': "example",
    'state': "example",
},
     {   headers: {
        "accept": "application/json, text/javascript, */*; q=0.01",
        "accept-encoding": "gzip, deflate, br",
        "accept-language": "en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7",
        "content-type": "application/json",
        "origin": "https://www.walmart.com",
        "referer": "https://www.walmart.com/checkout/",
        "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.69 Safari/537.36",
        'inkiru_precedence': false,
        "wm_vertical_id": "0",
        "upgrade-insecure-requests": "1"
        },
})
.then(response => { 
    console.log(response)
})
.catch(error => {
    console.log(error.response)
});

0 个答案:

没有答案