Skip to content

Refactor frontend ApiService to use Axios library instead of bare fetch API #45

@Wolven531

Description

@Wolven531

Currently, the ApiService uses the native fetch() API when communicating w/ the server. We should update it to use the Axios library for several reasons -

  • Axios has a simpler API for making requests
  • We can set the baseURL during APIService's setup so that each subsequent .get() or .post() is cleaner
  • Axios has some built in security features
  • Axios can deal directly w/ Promises, whereas fetch requires some tinkering

This ticket will involve a few steps -

  1. Adding Axios to project devDependencies
  2. Run npm i to make sure the package-lock.json stays up to date
  3. Use the Axios API docs to transform the ApiService class from using fetch() to using Axios
  4. This change will require that all the unit tests for ApiService are updated as well (or temp commented out until another story is created to update them); either step 1 or 2 below must be completed (but not both)
    1. Comment out the tests in ApiService.test.tsx except for a expect(true).toBeTruthy() (since config does not allow empty test files)
    2. Update the test files in ApiService.test.tsx to use a mocked Axios

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactorSomething needed some clean up or could be improvedsecurityChange improves or fixes one or more security holes

    Projects

    Status

    Todo

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions