Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fetch] Integrating devise-token-auth with react-native using fetch ? #1523

Closed
piyushchauhan2011 opened this issue Jun 5, 2015 · 2 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@piyushchauhan2011
Copy link

I want to integrate devise-token-auth with react-native.

fetch('http://localhost:3000/auth', {
      method: 'post',
      body: JSON.stringify({
        config_name: 'default',
        first_name: this.state.first_name,
        last_name: this.state.last_name,
        email: this.state.email,
        password: this.state.password,
        password_confirmation: this.state.password_confirmation,
      })
    })

Unable to post the json in correct format, am I doing something wrong ?

There is very less documentation on fetch api

@christopherdro
Copy link
Contributor

Your missing the proper headers.
Should look something like this...

fetch('http://localhost:3000/auth', {
  method: 'post',
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    config_name: 'default',
        first_name: this.state.first_name,
        last_name: this.state.last_name,
        email: this.state.email,
        password: this.state.password,
        password_confirmation: this.state.password_confirmation,
  })
})

More info at https://github.com/github/fetch#post-json

@brentvatne brentvatne changed the title Integrating devise-token-auth with react-native using fetch ? [fetch] Integrating devise-token-auth with react-native using fetch ? Jun 5, 2015
@piyushchauhan2011
Copy link
Author

Cool works perfect!

@facebook facebook locked as resolved and limited conversation to collaborators Jun 6, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

3 participants