gpt4 book ai didi

vue.js - axios 在配置 vue js 中设置 header

转载 作者:搜寻专家 更新时间:2023-10-30 22:28:40 24 4
gpt4 key购买 nike

现在我像这样使用 axios:

import axios from 'axios'
axios.get(apiObjUrl,
{
headers: {
'Content-type': 'application/x-www-form-urlencoded',
}
})
.then(({data}) => {

如何设置全局 axios header ?(我需要设置本地化 header 以在我的所有请求中使用)

最佳答案

使用 Axios 拦截器:https://github.com/mzabriskie/axios#interceptors

config 中,您有请求的 header 。

关于vue.js - axios 在配置 vue js 中设置 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45541241/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com