上QQ阅读APP看书,第一时间看更新
Listing users
The list method will use fetch to make a GET call to retrieve all the users in the database, and then return the response from the server as a promise to the component.
mern-skeleton/client/user/api-user.js:
const list = () => {
return fetch('/api/users/', {
method: 'GET',
}).then(response => {
return response.json()
}).catch((err) => console.log(err))
}