Nuxt 3 useFetch Authorization

105 views Asked by At

When sending the Authorization header I get a 401 error. When checking in postman, an error occurred

useFetch code:

await useFetch(`${config.public.baseUrl}/bus_stops`, {
        method: 'GET',
        watch: false,
        headers: {
            authorization: `Bearer ${authToken.value}`,
        },
        params: params,
        onResponse({response}) {
            busStops.value = [];
            // @ts-ignore
            busStops.value = response._data.data;
            isLoading.value = true;
        },
    });

I send an authorization token and expect a 200 response but get a 401

0

There are 0 answers