New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

ndume

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ndume

Ndume is a JavaScript class designed to simplify API calls using the fetch method. It provides a convenient way to make HTTP requests with support for various HTTP methods, request headers, and request body formats.

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

Ndume

Ndume is a JavaScript class designed to simplify API calls using the fetch method. It provides a convenient way to make HTTP requests with support for various HTTP methods, request headers, and request body formats.

Installation

Install the Ndume package using npm:


npm install ndume

## Usage
const Ndume = require('ndume');

// Create an instance of Ndume with the base API route
const api = new Ndume('https://api.example.com');

// Set an authorization token if required
api.setToken({
  type: 'Bearer',
  token: 'your_access_token',
});

// Make a GET request
api.GET('/endpoint')
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

API

new Ndume(baseRoute: string) Creates a new instance of Ndume with the specified base route.

setToken(token: { type: string, token: string }) Sets the authorization token for the requests.

BaseRequest(method: string, bodyType: string, body: any, path: string, params: Object): Promise Performs a basic request using the fetch method. Returns a Promise containing the fetch request response.

BodyTreatMent(body: any, bodyType: string): Promise Formats the request body to the proper format. Returns a Promise containing the formatted request body.

ParamThreatMent(params: Object): string Formats request parameters to a query string. Returns the formatted parameter string.

POST(body: any, bodyType: string, path: string, params: Object): Promise Performs a POST request. Returns a Promise containing the POST request response.

PUT(body: any, bodyType: string, path: string, params: Object): Promise Performs a PUT request. Returns a Promise containing the PUT request response.

GET(path: string, params: Object): Promise Performs a GET request. Returns a Promise containing the GET request response.

DELETE(path: string, params: Object): Promise Performs a DELETE request. Returns a Promise containing the DELETE request response.

PATCH(body: any, bodyType: string, path: string, params: Object): Promise Performs a PATCH request. Returns a Promise containing the PATCH request response.

License

Contribuições

Fique à vontade para contribuir para este projeto. Veja o arquivo CONTRIBUTING.md para obter detalhes.

Keywords

Ndume

FAQs

Package last updated on 10 Nov 2023

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