- Full-Stack React Projects
- Shama Hoque
- 78字
- 2021-06-25 21:45:18
Sign-out
The signout method will use fetch to make a GET call to the signout API endpoint on the server.
mern-skeleton/client/user/api-auth.js:
const signout = () => {
return fetch('/auth/signout/', {
method: 'GET',
}).then(response => {
return response.json()
}).catch((err) => console.log(err))
}
At the end of the api-auth.js file, export the signin and signout methods.
mern-skeleton/client/user/api-auth.js:
export { signin, signout }
With these API fetch methods, the React frontend has complete access to the endpoints available in the backend.