将fetch-get转换为axios方法



我目前正在努力将fetch-get请求转换为axios-get请求。

这是我的提取请求:

window.fetch(url, {
headers: {
'Origin': window.location.origin,
},
method: 'GET',
mode: 'cors',
cache: 'no-cache',
credentials: 'same-origin',
})

我正试图将其转换为axios,但很难找到缓存和凭据的相应属性。有人知道吗?

缓存:

const config = {
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache'
}
};
const { data } = await axios.get(url, config);

有关凭据,请使用credentials检查该属性。默认情况下,它设置为false。

最新更新