![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@meetup/fetch-request
Advanced tools
fetch-request
is a library that provides a simple way to perform HTTPS requests in your lambda.
This library comes with AWS XRay integration and tracing out of the box (our very own lambda-xray
package!) and
follows an async/await
pattern that we've been using in all our lambdas. We found ourselves copy-pasting a lot
of our code between repos, so we decided to centralize our best practice patterns.
npm install @meetup/fetch-request
import httpsHelper from '@meetup/fetch-request';
const callMyApi = async (): Promise<string> => {
const requestOpts = {
host: 'fun-api.com',
path: '/my-favorite-food?myname=juanbi',
method: 'GET',
};
const response: string = await httpsHelper.fetchRequest<string>(requestOpts);
return response;
};
You can also specify a payload and your own response/error handlers!
import httpsHelper from '@meetup/fetch-request';
const httpResponseHandler = <T>(
response: import('http').IncomingMessage,
buffer: string,
payload: string,
resolve: (data: T) => void,
reject: (error: RequestError) => void,
): void => {
if (response.statusCode && response.statusCode === 200) {
// Do something with this response!
const parsedBuffer = JSON.parse(buffer);
resolve(parsedBuffer);
} else {
// Do something else with error!
console.error('Error!');
reject({ message: 'Serious error..', error: "I'm not kidding", statusCode: 500 });
}
};
const callMyApi = async (): Promise<string> => {
const requestOpts = {
host: 'fun-api.com',
path: '/my-favorite-food?myname=juanbi',
method: 'GET',
};
const response: string = await httpsHelper.fetchRequest(requestOpts, 'IMPORTANT-PAYLOAD', httpResponseHandler);
return response;
};
We use the Node https
library behind the scenes, so check their documentation out for information on what types of options and requests you can make: https://nodejs.org/api/https.html
Made with :heart: by Comms Tools squad
FAQs
HTTP Request Helpers
The npm package @meetup/fetch-request receives a total of 1 weekly downloads. As such, @meetup/fetch-request popularity was classified as not popular.
We found that @meetup/fetch-request demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.