Skip to content

Instantly share code, notes, and snippets.

@amandeepmittal
Created November 4, 2018 16:07
Show Gist options
  • Save amandeepmittal/9b61c7d78a46bec8374453dcefbe00e4 to your computer and use it in GitHub Desktop.
Save amandeepmittal/9b61c7d78a46bec8374453dcefbe00e4 to your computer and use it in GitHub Desktop.
// api-auth.js
export const signin = user => {
return fetch('/auth/signin/', {
method: 'POST',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
},
credentials: 'include',
body: JSON.stringify(user)
})
.then(response => {
return response.json();
})
.catch(err => console.log(err));
};
export const signout = () => {
return fetch('/auth/signout/', {
method: 'GET'
})
.then(response => {
return response.json();
})
.catch(err => console.log(err));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment