Rafii Ferrynantyo

Results 4 comments of Rafii Ferrynantyo

this is how i handle it in nuxt ``` import type { FetchOptions } from 'ofetch' export default defineNuxtPlugin(() => { const authToken = useCookie('_auth_token') const refreshToken = useCookie('_refresh_token') const...

@JoyfulAndSpeedyMan have you tried to remove async/await on `onResponseError` ? ``` export default defineNuxtPlugin((nuxtApp) => { const api = $fetch.create({ onRequest(context) { // ........ }, onResponseError({ response }) { if...

IMHO, you should use `$fetch` instead of `useFetch` on `usApi` composables. and if you want to use it on server, you can wrap it using `useAsyncData`

> But when using $fetch i would need to reimplement all the already provided caching functionality, or? yes, you can use `useAsyncData` + `useApi` [custom fetcher](https://nuxt.com/docs/guide/recipes/custom-usefetch#custom-usefetch)