Socket
Socket
Sign inDemoInstall

digit-fetchy

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    digit-fetchy

Simple HTTP package using the new Fetch API.


Version published
Weekly downloads
5
increased by400%
Maintainers
1
Install size
8.20 kB
Created
Weekly downloads
 

Readme

Source

Fetchy

Simple HTTP package using the new Fetch API.

All responses default to JSON unless specified otherwise

Installation

GITHUB

git clone https://github.com/vjrngn/fetchy/

NPM

npm install 'digit-fetchy'

Usage

In any file :

var http = require('digit-fetchy');

GET request

Simple GET request with default headers

  http.get('some/url/here.com')
    .then(response => {
      console.log(response);
    })
    .catch(errors => {
      console.log(errors)
    });

GET request with custom headers

  let headers = {
    'Accept': 'application/json',
    'x-custom-header': 'foo'
  };

  http.get('some/url/here.com', headers)
    .then(response => {
      // json response here.
    })
    .catch(errors => {
      // any errors here
    });

POST request

Simple POST request with default headers

  let data = {
    name: 'John',
    password: 'foobar'
  };

  http.post('some/url/here.com', data)
    .then(response => {
      // json response here
    })
    .catch(errors => {
      // any errors here
    });

POST request with custom headers

  let data = {
    name: 'John',
    password: 'foobar'
  };

  let headers = {
    'x-foo': 'bar'
  };

  http.post('some/url/here.com', data, headers)
    .then(response => {
      // json response here
    })
    .catch(errors => {
      // any errors here
    });

PUT request

    let data = {
    name: 'John',
    password: 'foobar'
  };

  let headers = {
    'x-foo': 'bar'
  };

  http.put('some/url/here.com', data, headers)
    .then(response => {
      // json response here
    })
    .catch(errors => {
      // any errors here
    });

Request Options

Request OptionsDescriptionValues
modeThe mode contains the mode of the request (e.g., cors, no-cors, cors-with-forced-preflight, same-origin.) This is used to determine if cross-origin requests lead to valid responses, and which properties of the response are readablesame-origin, no-cors, cors (default)
credentialsIndicates whether the user agent (browser) should send cookies from the other domain in the case of cross-origin requests. This is similar to XHR’s withCredentials flag, but with three available values (instead of two).omit, same-origin, include (default)
cacheIndicates the cache mode of the request.default (default), no-store , reload, no-cache, force-cache

Keywords

FAQs

Last updated on 30 Jun 2016

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc