neiist-dev / neiist-website

A website where you can keep up to date with NEIIST. A platform to help students find the right Master's thesis. A place for NEIIST's members to get involved with the association.
https://neiist.tecnico.ulisboa.pt
5 stars 7 forks source link

API Service File #220

Closed nelsontr closed 1 year ago

nelsontr commented 1 year ago

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);
        },
      );