node-api-request
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

Node API Request


Node-API-Request is a versatile and lightweight module designed to streamline the process of making HTTP requests in Node.js. Whether you're fetching data from APIs, downloading resources, or interacting with web services

Build status Package size Downloads Npm version

Installation

To install the package, use the following command:

npm install --save node-api-request

Initialization

You can initialize the Node-API-Request using either CommonJS or ES6 syntax:

// CommonJS
const NodeApiRequest = require("node-api-request");

// ES6
import NodeApiRequest from 'node-api-request';

Usage

import NodeApiRequest, { RequestOptions, ApiResponse } from 'node-api-request';

async function main() {
  const apiUrl = 'https://jsonplaceholder.typicode.com/todos/1';
  const requestOptions: RequestOptions = {
    url: apiUrl,
    method: 'GET',
  };

  try {
    const response: ApiResponse = await NodeApiRequest.sendRequest(requestOptions);

    console.log('Response Status:', response.status);
    console.log('Response Body:', response.body);
  } catch (error) {
    console.error('Error:', error);
  }
}

Package Sidebar

Install

npm i node-api-request

Weekly Downloads

1,013

Version

1.0.4

License

MIT

Unpacked Size

10 kB

Total Files

13

Last publish

Collaborators

  • jaynath-d