Created
May 31, 2019 08:55
-
-
Save anchetaWern/5ea94a7175cf2afa4438f048d3c368ee to your computer and use it in GitHub Desktop.
React Native Stream Group Chat Tutorial: Login code
This file contains 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
// src/screens/Login.js | |
login = async () => { | |
const username = this.state.username; | |
this.setState({ | |
is_loading: true | |
}); | |
if (username) { | |
try { | |
const user_id = StringHash(username).toString(); | |
const response = await axios.post(`${CHAT_SERVER}/auth`, { | |
user_id | |
}); | |
this.props.navigation.navigate("Chat", { | |
user_id, | |
username, | |
user_token: response.data.token | |
}); | |
} catch (err) { | |
console.log("error: ", err); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment