diff --git a/docs/3.api/1.composables/use-fetch.md b/docs/3.api/1.composables/use-fetch.md index 364ff36684c5..9541b15ad951 100644 --- a/docs/3.api/1.composables/use-fetch.md +++ b/docs/3.api/1.composables/use-fetch.md @@ -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 diff --git a/examples/other/use-custom-fetch-composable/composables/useCustomFetch.ts b/examples/other/use-custom-fetch-composable/composables/useCustomFetch.ts index 56365292b7b8..2464b3cd45ff 100644 --- a/examples/other/use-custom-fetch-composable/composables/useCustomFetch.ts +++ b/examples/other/use-custom-fetch-composable/composables/useCustomFetch.ts @@ -15,12 +15,12 @@ export function useCustomFetch (url: string, options: UseFetchOptions = {} ? { 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() } }