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

Replace axios with native fetch #564

Merged
merged 6 commits into from
Nov 21, 2024
Merged

Replace axios with native fetch #564

merged 6 commits into from
Nov 21, 2024

Conversation

mgwalker
Copy link
Member

Axios doesn't really provide us much benefit over native fetch, so yoink it out and that's one less dependency to worry about!

Will update dev documentation just prior to merging.


Checklist:

  • Code has been formatted with prettier
  • The OAuth wiki page has been updated if Charlie needs any new OAuth events or scopes
  • The Environment Variables wiki page has been updated if new environment variables were introduced or existing ones changed
  • The dev wiki has been updated, e.g.:
    • local development processes have changed
    • major development workflows have changed
    • internal utilities or APIs have changed
    • testing or deployment processes have changed
  • If appropriate, the NIST 800-218 documentation has been updated

@mgwalker mgwalker requested a review from a team as a code owner November 20, 2024 18:23
src/scripts/dot-gov.js Dismissed Show dismissed Hide dismissed
const { data } = await axios.get(config.responseUrl);
return data;
},
async () => fetch(config.responseUrl).then((r) => r.json()),

Check warning

Code scanning / CodeQL

File data in outbound network request Medium

Outbound network request depends on
file data
.
axios.get.mockResolvedValue({
data: `
fetch.mockResolvedValue({
text: async () => `
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok this looked weird but i looked at the whole file in context and figured it out

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a comment that it needs to be formatted like yaml so maybe it looks weird to the next person. Would that help?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think it's necessary, it was easy enough to see when i opened the file!

Copy link
Member

@Sgtpluck Sgtpluck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a couple small questions but nothing blockin! nice work.

.then((response) => {
if (response && response.status) {
if (response?.ok && response.status) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh i didn't know js had a null-chaining operator!

"https://www.opm.gov/json/operatingstatus.json",
);
if (status !== 200) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[question] can we get rid of this error throw because data is more consistent now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup

@mgwalker mgwalker enabled auto-merge November 21, 2024 19:07
@mgwalker mgwalker merged commit 2704194 into main Nov 21, 2024
6 checks passed
@mgwalker mgwalker deleted the remove-axios branch November 21, 2024 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants