Skip to content

Instantly share code, notes, and snippets.

@phpsmarter
Created February 20, 2018 00:26
Show Gist options
  • Save phpsmarter/36561865f7536dabc77b67627986a599 to your computer and use it in GitHub Desktop.
Save phpsmarter/36561865f7536dabc77b67627986a599 to your computer and use it in GitHub Desktop.
apollo-client mutation
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