The remove method will allow the view component to delete a specific user from the database, using fetch to make a DELETE call. This, again, is a protected route that will require a valid JWT as a credential, similar to the read and update methods. The response from the server to the delete request will be returned to the component as a promise.
mern-skeleton/client/user/api-user.js:
const remove = (params, credentials) => { return fetch('/api/users/' + params.userId, { method: 'DELETE', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Authorization': 'Bearer ' + credentials.t } }).then((response) => { return response.json() }).catch((err) => { console.log(err) }) }
Finally, export the user API ...