在react-native中使用devise_token_auth获取

时间:2017-07-20 01:51:35

标签: react-native devise rails-api

我是反应原生的新人。我试图在每个请求中满足发送标头的发送的devise_token_auth要求。为此,我尝试这样的事情:

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))
  }
}

我的后端正在接收请求,所有标头都已填满。但是,我仍然收到消息"_bodyText":"{\"errors\":[\"You need to sign in or sign up before continuing.\"]}"

我该如何做到这一点?我跳了吗?

0 个答案:

没有答案