API Service File
Closed this issue · 0 comments
nelsontr commented
We should have a specific file with all API calls we do, to maintain the code readability and maintainability.
Example:
From
fetch(`/api/members/${userData.username}`)
.then((res) => res.json())
.then((fetchMember) => {
setMember(fetchMember);
setIsLoaded(true);
},
(err) => {
setIsLoaded(true);
setError(err);
},
);
To
APIService.fetchMember(username)
.then(fetchMember) => {
setMember(fetchMember);
setIsLoaded(true);
},
(err) => {
setIsLoaded(true);
setError(err);
},
);