Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Wolven531 opened this issue Jul 8, 2021 · 0 comments
Labels
refactor Something needed some clean up or could be improved security Change improves or fixes one or more security holes

Comments

@Wolven531
Copy link
Owner

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

@Wolven531 Wolven531 added security Change improves or fixes one or more security holes refactor Something needed some clean up or could be improved labels Jul 8, 2021
@Wolven531 Wolven531 added this to the MVP (Minimum Viable Product) milestone Jul 8, 2021
@Wolven531 Wolven531 changed the title Refactor frontend ApiService to Axios library instead of bare fetch API Refactor frontend ApiService to use Axios library instead of bare fetch API Jul 8, 2021
@Roughnick Roughnick self-assigned this Jul 9, 2021
@Roughnick Roughnick removed their assignment Aug 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Something needed some clean up or could be improved security Change improves or fixes one or more security holes
Development

No branches or pull requests

2 participants