Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请求拦截的问题 #3

Open
Thinker-feiluo opened this issue Apr 23, 2024 · 1 comment
Open

请求拦截的问题 #3

Thinker-feiluo opened this issue Apr 23, 2024 · 1 comment

Comments

@Thinker-feiluo
Copy link

您好,您这个项目有做请求拦截吗?就是类似于useFetch的
const { data, pending, error, refresh } = await useFetch('/api/auth/login', {
onRequest({ request, options }) {
// 设置请求头
options.headers = options.headers || {}
options.headers.authorization = '...'
},
onRequestError({ request, options, error }) {
// 处理请求错误
},
onResponse({ request, response, options }) {
// 处理响应数据
localStorage.setItem('token', response._data.token)
},
onResponseError({ request, response, options }) {
// 处理响应错误
}
})
这几个功能

@small-universe
Copy link
Contributor

看了一下代码,是有这个拦截的
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants