Created
February 20, 2018 00:26
-
-
Save phpsmarter/36561865f7536dabc77b67627986a599 to your computer and use it in GitHub Desktop.
apollo-client mutation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
signup = async () => { | |
const { email, password } = this.state; | |
try { | |
const result = await this.props.signupUserMutation({ | |
variables: { | |
email, | |
password, | |
}, | |
}); | |
// Store the ID and token in local storage. | |
localStorage.setItem('SHORTLY_ID', result.data.signupUser.id); | |
localStorage.setItem('SHORTLY_TOKEN', result.data.signupUser.token); | |
this.props.history.push('/'); | |
} catch (err) { | |
// TODO: Handle the error properly | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment