Modificar header Accept sin interceptor #276
-
"¿Es posible modificar el encabezado Accept: application/json directamente en las solicitudes sin necesidad de utilizar un interceptor? En caso afirmativo, ¿podrían proporcionar un ejemplo de cómo configurarlo correctamente?" |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @WilianMarroquin, since this module provides a simple wrapper on top of const sanctumFetch = useSanctumClient()
await sanctumFetch(
'/api/endpoint',
{
headers: {
CustomHeader: 'custom-value',
},
},
) However, the module may override some of the values because the header processing order might differ. Another disadvantage is that you have to repeat the same approach every time you want to pass a custom header, so interceptors can solve this more efficiently. |
Beta Was this translation helpful? Give feedback.
Hey @WilianMarroquin, since this module provides a simple wrapper on top of
ofetch
, you can try doing something like thisHowever, the module may override some of the values because the header processing order might differ. Another disadvantage is that you have to repeat the same approach every time you want to pass a custom header, so interceptors can solve this more efficiently.