Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- handleSubmit(context) {
- let json = {
- username: this.state.username,
- password: this.state.password,
- }
- json = JSON.stringify(json)
- fetch(`/api/auth/token/`, {
- method: 'POST',
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- body: json,
- })
- .then(response => response.json())
- .then(response => this.loginSuccess(context, response))
- }
- loginSuccess(context, response) {
- console.log('Login Success!')
- context.toggleLoginModal()
- context.toggleLoggedIn()
- context.setUsername(response.profile_username)
- context.setUserId(response.profile_id)
- }
- .then(response => response.json())
- .then(response => this.loginSuccess(context, response))
- .then(response => {
- response.status >= 200 && response.status < 300 ?
- this.loginSuccess(context, response.json())
- :
- console.log(response)
- })
Add Comment
Please, Sign In to add comment