Socket
Socket
Sign inDemoInstall

eh-api-client

Package Overview
Dependencies
54
Maintainers
2
Versions
96
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    eh-api-client

Node.js rest client


Version published
Weekly downloads
486
increased by23.35%
Maintainers
2
Install size
4.63 MB
Created
Weekly downloads
 

Readme

Source

Require

var ClientFactory = require("eh-api-client");
var factory = new ClientFactory("http://someservice.com/v1"); // initialize new factory with root API url

Getting client for user

var client = factory.getClient(50, "web"); // get client for userId = 50 and app = "web"

Getting client for guest user

var client = factory.getClient(0, "web"); // you can pass 0/null/undefined/"" as first argument to initialize guest client

Request options

You can pass request options in the first argument of request. Options are:

  • qs - query string parameters
  • url - request URL path
  • formData - form data
  • encoding
  • filter - data filter rules
  • range - data range rule
  • order - order rule
  • headers
  • timeout - request timeout
  • notFoundIsNull - if specified if request returns 404 status code then null will be returned instead of throwing error
  • retryOnTransientError - if specified then request will be retried if it fails on transient errors. By default only read only requests can be retried. With this option you can retry any request.

Events

request-done

Emitted when request is done without any network error. Event data:

{
  method,
  url,
  options,
  statusCode
}

network-error

Emitted when network error has occured. Event data:

{
  method,
  url,
  options,
  err
}

FAQs

Last updated on 20 Jul 2023

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