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

remote-json

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remote-json

HTTP/HTTPS client for JSON APIs

latest
Source
npmnpm
Version
4.1.3
Version published
Maintainers
1
Created
Source

remote-json

Node.js HTTP/HTTPS client for JSON APIs. Supports GET, PUT, POST, DELETE and PATCH methods.

npm install('remote-json')

Usage

var remote = require('remote-json');

remote('http://echo.jsontest.com/key/value/name/Bob')
    .get(function (err, res, body) {
        console.log(res.statusCode); // 200
        console.log(body); // {"name": "Bob", "key": "value"}
    });

API

remote(url[, opt])

Returns a new instance of Remote object with JSON API's methods.

  • url - A full URL string.
  • opt - A HTTP options object.

Remote.get([path,][data,] callback)

Returns a function for GET method.

  • path - Optional. A path which will be added to the URL.
  • data - Optional. A data wich will be send with request.
  • callback - Callback function.

Many paths at one remote:

var remote = remote('http://json.api');
remote.get('/users', callbackUsers);
remote.get('/books', callbackBooks);

Send data on request:

remote.get('/users', {id: 123}, callback);
remote.get('/users', {id: 78}, callback);

Remote.[post, put, del, patch]

Usage for these methods is equal to the one of the .get method.

HTTP JSON Content Types

According to the standard, the MIME media type for JSON text is application/json. This module checks if the type is valid. You may enable any other type to pass the validation, e.g.:

remote.contentTypes['text/javascript'] = true;

HTTP options

Pass it to the constructor:

remote('http://json.api', {
    headers: {
        Cookie: 'Your cookie'
    }
});

Redirects

This client doesn't follow redirects. Use the follow-redirects module for this:

remote.http = require('follow-redirects').http;
remote.https = require('follow-redirects').https;

Tests

npm test

The tests use online services:

They may be down for the momemnt you test this module.

Keywords

JSON

FAQs

Package last updated on 13 Oct 2017

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