Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing token via general.js file #8

Open
emil126a opened this issue Oct 10, 2018 · 4 comments
Open

Passing token via general.js file #8

emil126a opened this issue Oct 10, 2018 · 4 comments

Comments

@emil126a
Copy link

axios.defaults.headers.common["Authorization"] does not work. Each request call says "Token not provided". Would be nice if you fixed.

@zayyarmin3
Copy link

@emil126a
I had the same issue with the Authorization Header is not set after page refresh.
I solve this by creating created method and reinitialize the Authorization Header if user is found in the local storage.

var app = new Vue({
    el: '#app',
    router,
    store,
    components: {
        'main-app': MainComponent
    },
    created() {
        const user = getUser();
        if(user) {
            setAuthenticationHeader(user.token);
        }
    }
});

@ajcastro
Copy link

Make sure the value of Authorization has a prefix of "Bearer "+token
Take note it should have a space in between, something like "Bearer ad45tegdzgftryhgcxbsydhtv5y"

@boyet007
Copy link

boyet007 commented Dec 9, 2018

const user = getUser();

getUser is not defined...

@zayyarmin3
Copy link

Ah. Sorry I forgot to mention. You gotta have to import those methods from auth.js in helper folder.
LIke This

import {setAuthenticationHeader, getUser} from './helpers/auth';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants