-
Notifications
You must be signed in to change notification settings - Fork 5
Refactor Gist Web to use Fetch API #82
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
Conversation
To replace axios Part of INAPP-12465 Part of INAPP-13292
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the network service to replace axios with the Fetch API, streamlining network requests for the Gist Web application.
- Replaces axios with the Fetch API and AbortController for timeouts.
- Reorganizes baseURL selection and header construction based on API version and user token.
- Implements a POST helper function with JSON serialization.
Comments suppressed due to low confidence (1)
src/services/network.js:49
- [nitpick] Consider wrapping the thrown error in an instance of Error (e.g., new Error(...)) to preserve the stack trace and ensure consistent error handling.
throw {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple opportunities for simplification, but nothing blocking from my perspective. 👌
}); | ||
|
||
if (response.status < 200 || response.status >= 400) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 This could be simplified by using the ok
Response attribute.
if (response.status < 200 || response.status >= 400) { | |
if (!response.ok) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its because we also need to handle 304s.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bernard is correct, we return a 304 Not Modified when users hit the cache for messages instead of going to Firestore.
Part of INAPP-13292
Part of INAPP-13292 Related PR: customerio/gist-web#82
Part of INAPP-13292 Related PR: customerio/gist-web#82
does this mean that the dependency on axios can be removed? it doesn't seem to be used anymore, and the referenced version has a CVE vulnerability axios/axios#6463 |
Yes, I have opted to refactor using fetch api instead of updating axios. |
Thank you! Will there be a new release without the axios dependency (since it's still referenced in the package.json right now)? |
Ah, yes, of course! I will remove the dependency and release again. |
Leftovers from PR #82 Part of INAPP-13292
Thank you! |
To replace axios
Part of INAPP-12465
Part of INAPP-13292