docs: fix fetch composable examples (#20603)

This commit is contained in:
Enkot 2023-05-01 15:41:17 +03:00 committed by GitHub
parent c536e5a635
commit ecb2fda113
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -114,7 +114,7 @@ const { data, pending, error, refresh } = await useFetch('/api/auth/login', {
},
onResponse({ request, response, options }) {
// Process the response data
return response._data
localStorage.setItem('token', response._data.token)
},
onResponseError({ request, response, options }) {
// Handle the response errors

View File

@ -15,12 +15,12 @@ export function useCustomFetch<T> (url: string, options: UseFetchOptions<T> = {}
? { Authorization: `Bearer ${userAuth.value}` }
: {},
onResponse (__ctx) {
// return new myBusinessResponse(response._data)
onResponse (_ctx) {
// _ctx.response._data = new myBusinessResponse(_ctx.response._data)
},
onResponseError (__ctx) {
// return new myBusinessError(error)
onResponseError (_ctx) {
// throw new myBusinessError()
}
}