Create global instance of ofetch
I want to create a global ofetch instance, on which I can add custom header and I want it to be present on all $fetch and useFetch calls from.
What is the best way to do this, if it is even possible?
2 Replies
https://notes.atinux.com/nuxt-custom-fetch
Or if you really want to override $fetch: https://stackoverflow.com/a/75871291
also linking https://www.youtube.com/watch?v=jXH8Tr-exhI
Alexander Lichter
YouTube
Custom $fetch and Repository Pattern in Nuxt 3
💻 The repository pattern is a popular way to abstract your API calls away and provide a descriptive way to retrieve or send data. But how would you implement it in Nuxt? And should you use composables or $fetch for it? This video will give answers to all the questions!
Key points:
🎛️ Implementing the repository pattern in Nuxt
🔛 Creating our ow...