Skip to content

Instantly share code, notes, and snippets.

@YKalashnikov
Last active July 4, 2019 00:56
Show Gist options
  • Save YKalashnikov/24219b90c01d08941c84fdfe077acf21 to your computer and use it in GitHub Desktop.
Save YKalashnikov/24219b90c01d08941c84fdfe077acf21 to your computer and use it in GitHub Desktop.
export const userLoginFetch = user => {
return dispatch => {
return fetch("http://localhost:3000/api/v1/login", {
method: "POST",
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
},
body: JSON.stringify({user})
})
.then(resp => resp.json())
.then(data => {
if (data.message) {
//тут ваша логика
} else {
localStorage.setItem("token", data.jwt)
dispatch(loginUser(data.user))
}
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment