Get user/session returns 401 error

Hi,

I’m trying to implement a function in a mobile app that checks whether the user is signed in, by using a get request to user/session.

I can successfully send a POST request to user/session and received the user_token.

But when i try and do a get request with the received token i get a 401 error.

This is what i did.

checkUserState() {
console.log(toString(this.state.token));
axios.get(url, {
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'X-DreamFactory-Session-Token': this.state.token,
    'X-DreamFactory-Api-Key': apiKey
  }
})
.then(response => {
  console.log(response.status);
})
.catch(error => console.log(error));
}

Any help would be greatly appreciated. Thanks!

Never mind, i got it to work, the problem was in the order of execution of my code.
What happened was i sent the get request before the token was set to state.