1
export const login = user => {
    return fetch("users/login", {
        method: 'POST',
        body: JSON.stringify({
            email: user.email,
            password: user.password
        }),
        headers : {'Content-type':'application/json','Authorization':'Bearer'+user.token}
    }).then(response =>{
        console.log("hjhsfdgsdhgfsdggd"+response.formData.token)

        // On below line it thorws an exception
        window.localStorage.setItem('usertoken',response.formData.token)
        return response.formData.token
    }).catch(err =>{
        console.log(err);
    })
}

The highlighted code throws the error:

SyntaxError: Unexpected token export on debugging

and while viewing in the local storage the key comes as undefined

I am using jwt for token authentication

Dinko Pehar
  • 5,454
  • 4
  • 23
  • 57
  • 1
    its not related to code it might be related to file export, check out [this](https://stackoverflow.com/questions/38296667/getting-unexpected-token-export) – Prashant Pimpale Nov 27 '18 at 10:13

0 Answers0