Get user/session returns 401 error




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() {
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 => {
.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.