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

fetch-nodejs

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-nodejs

fetch method implementation for Nodejs

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

fetch-nodejs

Implementation of Fetch API.

API implemented according to recomendations on MDN Fetch API.

Installation

Install Fetch as an npm module and save it to your package.json file as a dependency:

npm install --save fetch-nodejs

Usage

Library provides fetch() method. It accepts string url as necessary parameter and optional object with properties param: Params and headers: Headers. Params and Headers types extend Map, therefore to set params or headers of request use set() method with the name and value arguments.

fetch() method returns promise that resolves to Response type object. Use res.json() to get json result.

Example

    const { fetch, Params } = require('fetch-nodejs');

    const params = new Params()
        .set('page_index', 12)
        .set('page_size', 10)

    fetch('http://test-api.tech/rest/users', { params: params })
    .then(res => res.json())
    .then(
        res => console.log(res), 
        err => console.log('Error', err)
    )

Keywords

FAQs

Package last updated on 02 Jan 2018

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