[英]How to request anonymously via Axios?
我想通過 axios 向 url 發送 GET 請求。
該網站似乎可以通過 cookies 識別我,並將 url 重定向到登錄用戶移動到的頁面。
我想發送一個請求,就像我是從一個隱身標簽一樣
我嘗試過使用withCredentials: false
config。
在我的情況下,這似乎對true
或false
沒有任何影響。
axios({
url : url,
method: 'get',
maxRedirects: 15,
headers: {
'Content-Type': 'text/html',
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods':'GET',
},
withCredentials: false, // without cookies so no login
})
.then((res) => {
console.log("Response", res.data)
})
.catch((err) => {
console.log("Error with fetch: ", err)
})
});
我無法通過 axios 實現這一目標。 但是找到了一種方法來獲取 api
我得到了完美的 output 沒有以前的 cookies 或登錄
fetch(url, {
credentials: 'omit',
}).then((response)=>{
return response.text();
}).then((data)=>{
console.log(data);
}).catch(err=>{
console.log(err);
})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.