Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fetch-request-node

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-request-node

The fetch-request-node package makes working with external APIs simple and efficient. This intuitive wrapper leverages the power of the Fetch API, providing a clean and concise interface for your API interactions.

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Fetch Request Node

The fetch-request-node package makes working with external APIs simple and efficient. This intuitive wrapper leverages the power of the Fetch API, providing a clean and concise interface for your API interactions.

If you are working on a browser-based environment, make use of fetch-request-browser instead.


Getting Started

Install the package:

$ npm install -S fetch-request-node

Usage

import { sendGET } from 'fetch-request-node';

await sendGET('https://httpbin.org/get');
// {
//   code: 200,
//   headers: Headers {
//     date: 'Tue, 04 Jun 2024 18:52:29 GMT',
//     'content-type': 'application/json',
//     'content-length': '407',
//     connection: 'keep-alive',
//     server: 'gunicorn/19.9.0',
//     'access-control-allow-origin': '*',
//     'access-control-allow-credentials': 'true'
//   },
//   data: {
//     args: {},
//     headers: {
//       Accept: 'application/json',
//       'Accept-Encoding': 'br, gzip, deflate',
//       'Accept-Language': '*',
//       'Content-Type': 'application/json',
//       Host: 'httpbin.org',
//       'Sec-Fetch-Mode': 'cors',
//       'User-Agent': 'node',
//       'X-Amzn-Trace-Id': '...'
//     },
//     origin: '...',
//     url: 'https://httpbin.org/get'
//   }
// }

API

Build and send an HTTP Request (any method):

send(
  input: IRequestInput, 
  options?: Partial<IOptions>
): Promise<IRequestResponse>

Build and send a GET HTTP Request:

sendGET(
  input: IRequestInput,
  options?: Partial<IOptions>
): Promise<IRequestResponse>

Build and send a POST HTTP Request:

sendPOST(
  input: IRequestInput,
  options?: Partial<IOptions>
): Promise<IRequestResponse>

Build and send a PUT HTTP Request:

sendPUT(
  input: IRequestInput,
  options?: Partial<IOptions>
): Promise<IRequestResponse>

Build and send a PATCH HTTP Request:

sendPATCH(
  input: IRequestInput,
  options?: Partial<IOptions>
): Promise<IRequestResponse>

Build and send a DELETE HTTP Request:

sendDELETE(
  input: IRequestInput,
  options?: Partial<IOptions>
): Promise<IRequestResponse>

Built With

  • TypeScript

Running the Tests

# Unit Tests
$ npm run test:unit

# Integration Tests
$ npm run test:integration

License

MIT


Acknowledgments


@TODOS

  • Improve the docs

Deployment

Install dependencies:

$ npm install

Build the library:

$ npm start

Publish to npm:

$ npm publish

Keywords

FAQs

Package last updated on 16 Aug 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc