April 2020
Intermediate to advanced
716 pages
18h 55m
English
We will add a signout method to api-auth.js, which will use fetch to make a GET call to the signout API endpoint on the server.
mern-skeleton/client/auth/api-auth.js:
const signout = async () => { try { let response = await fetch('/auth/signout/', { method: 'GET' }) return await response.json() } catch(err) { console.log(err) }}
This method will also return a promise to inform the component about whether the API request was successful.
At the end of the api-auth.js file, we will export the signin and signout methods.
mern-skeleton/client/auth/api-auth.js:
export { signin, signout }
Now, these methods can be imported into the relevant React components so that we can implement the user sign-in and signout features.
With these API fetch ...
Read now
Unlock full access