You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 -
Adding Axios to project devDependencies
Run npm i to make sure the package-lock.json stays up to date
Use the Axios API docs to transform the ApiService class from using fetch() to using Axios
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)
Comment out the tests in ApiService.test.tsx except for a expect(true).toBeTruthy() (since config does not allow empty test files)
Update the test files in ApiService.test.tsx to use a mocked Axios
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
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 -.get()
or.post()
is cleanerPromise
s, whereas fetch requires some tinkeringThis ticket will involve a few steps -
npm i
to make sure thepackage-lock.json
stays up to dateApiService
class from usingfetch()
to using Axiosexpect(true).toBeTruthy()
(since config does not allow empty test files)Notes
The text was updated successfully, but these errors were encountered: