N
N
NewUser42422021-08-25 16:06:26
Vue.js
NewUser4242, 2021-08-25 16:06:26

Error Cannot set headers after they are sent to the client?

I am developing an application on vue.js, NUXT is used as SSR. The default component (rendered always) uses type checking

The code

async created() {
    const isToken= this.$cookies.get('token_auth');
    if (isToken) {
        this.$axios.defaults.headers.Authorization = `JWT ${token}`;
        await this.doSometThing(); ( запрос в VueX)
         } 
    }


And as a result, sometimes an error slips by type
Mistake

ERROR Cannot set headers after they are sent to the client
...

I do not quite understand what to do as I have not encountered this. Does anyone have options?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2021-08-25
@NewUser4242

it's a classic: headers must be sent BEFORE any other output.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question