samedi 27 mai 2017

Heroku javascript localstorage

I am using Heroku for a hobby application. On my app, I have a frontend which at times stores the token for a user like so:

/**
 * Fetch JSON Web token to be used for requests
 */
let token = localStorage.getItem('id_token');

Then in the same file, before I make requests to my API I check that the token exists like so:

 fetchClient(context, id) {
    if (token !== null) {
        axios.get(
            'api/clients/' + id + '?token=' + token,
        ).then(response => {
            let responseData = response.data;
            context.client = responseData.data;
        })
    }
}

This works fine on my local however after deploying my app to heroku, the request is not made as it seems that the token is not available in local storage?

Is there a way to get around this?

Thanks



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2rsd0Vt
via IFTTT

Aucun commentaire:

Enregistrer un commentaire