Hey guys, how do you set a token in your headers in nuxt3.
I am trying to set my django backend jwt token in my request headers after i fetch it.Right now im getting it from the cookies and setting in my fetches everytime.
1 Reply
That would be
See the docs here: https://nuxt.com/docs/api/composables/use-fetch#type
To keep it DRY, I would suggest creating a customFetch composable that will bake that behaviour in. Check this: https://nuxt.com/docs/examples/advanced/use-custom-fetch-composable
Nuxt
Use Custom Fetch Composable · Nuxt Examples
This example shows a convenient wrapper for the useFetch composable from nuxt. It allows you to customize the fetch request with default values and user authentication token.