Fetch with devise_token_auth in react-native

Viewed 372

I'm new with react-native. I'm trying to satisfy the devise_token_auth requirement of send in every request the authetication headers. To do so, I'm trying something like this:

export const scheduleFetch = (auth) => {
  return (dispatch) => {
    fetch(URL, {
      method: 'GET',
      headers: {
        'Content-Type': 'application/json; charset=utf-8',
        'access-token': auth['acessToken'],
        'token-type': auth['tokenType'],
        'client': auth['client'],
        'uid': auth['uid']
      }
    })
    .then((response) => {
      console.log(response)
      response.json()
    })
    .catch((error) => console.log(error))
  }
}

My back-end is receiving the request, all headers are fill. However, I still receiving the message "_bodyText":"{\"errors\":[\"You need to sign in or sign up before continuing.\"]}".

How can I make that work? Am I jumping any step?

0 Answers
Related