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

chore: use node-fetch instead of request #1422

Merged
merged 5 commits into from
May 15, 2024

Conversation

helios2003
Copy link
Contributor

Description
Using node-fetch library instead of request since the latter is deprecated.

Related issue(s)
Fixes #1421

@Shurtu-gal
Copy link
Collaborator

/update

console.log('Fetched ZIP file');
resolve();
}).on('error', reject);
fetch(SPEC_EXAMPLES_ZIP_URL)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Error handling can be improved by wrapping by a try/catch block (see: https://github.com/node-fetch/node-fetch?tab=readme-ov-file#handling-exceptions)

}
const file = fs.createWriteStream(TEMP_ZIP_NAME);
res.body.pipe(file);
file.on('close', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Listen also the the error event

file.on('error', (err) => {
                    reject(err);
                });

@helios2003
Copy link
Contributor Author

Done with the changes @Amzani

@helios2003
Copy link
Contributor Author

Also, currently, we are using node-fetch v2.0.0 because we are using CommonJS syntax. The library only supports ES6 module syntax in the updated v3, so should we change it? (Even though they mention that critical bug fixes will be published for v2)
Ref: https://www.npmjs.com/package/node-fetch#commonjs

Copy link
Collaborator

@Amzani Amzani left a comment

Choose a reason for hiding this comment

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

LGTM

@helios2003 helios2003 changed the title chore: use node-fetch insted of request chore: use node-fetch instead of request May 14, 2024
Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@Shurtu-gal
Copy link
Collaborator

/rtm

@asyncapi-bot asyncapi-bot merged commit 01f068a into asyncapi:master May 15, 2024
11 checks passed
@asyncapi-bot
Copy link
Contributor

🎉 This PR is included in version 1.14.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Replace request by node-fetch
4 participants