Skip to content

Set header after login? #8

@cannap

Description

@cannap

I have a question what is the best way to set the Header in
auth.login() {}?

current solution:

import Vue from 'vue';
....

   login(context, creds, redirect) {
        context.$http.post(LOGIN_URL, creds).then((data) => {

            localStorage.setItem('id_token', data.data.id_token)
            Vue.http.headers.common['Authorization'] = 'Bearer ' + localStorage.getItem('id_token');

            this.user.authenticated = true
            if (redirect) {
                router.go(redirect)
            }
        }).catch(({data}) => {
            context.error = data
        })


    },

i solve in a other way i switch to VUEX thank for the tutorial

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions