Socket
Socket
Sign inDemoInstall

api-http

Package Overview
Dependencies
9
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    api-http

Simple Node.js class for performing HTTP API requests.


Version published
Weekly downloads
14
decreased by-81.58%
Maintainers
1
Install size
552 kB
Created
Weekly downloads
 

Readme

Source

api-http

NPM Version Build Status

Simple Node.js class for performing HTTP requests.

npm install api-http

Example Usage

import ApiHttp from 'api-http';

const facebook = new APIHTTP('https://graph.facebook.com/v2.5/');

const person = await facebook.get('me')
console.log(person.first_name);

Methods

.get(), .delete(), .head()

Arguments: [path, query]

Example Usage:

var api = require('api-http')('http://example.com/');
// http://example.com/users?online=true
api.get('users', {online: true});

.post(), .patch(), .put(), ... etc.

Arguments: [path, body, query]

Example Usage:

api.post('customers', {
  firstName: 'John',
  lastName: 'Smith'
});

.withAccessToken(accessToken)

Create a new APIHTTP client scoped with an OAuth Bearer access token:

Example:

facebook.withAccessToken('2348923984324').get('me')

.withBasicAuth(username, password)

Create a new APIHTTP client scoped with a Basic Access Authorization header:

Example:

api.withBasicAuth('Aladdin', 'open sesame').get('something/x/y')

Keywords

FAQs

Last updated on 12 May 2020

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