Socket
Socket
Sign inDemoInstall

@agnostack/aftership-request

Package Overview
Dependencies
9
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @agnostack/aftership-request

Please contact agnoStack via info@agnostack.com for any questions


Version published
Weekly downloads
11
increased by450%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

@agnostack/aftership-request

🎮 Minimal AfterShip API request library for Node

Installation

yarn add @agnostack/aftership-request # npm install @agnostack/aftership-request

Quickstart (OAuth)

const { createClient } = require('@agnostack/aftership-request');
// import { createClient } from '@agnostack/aftership-request'

const aftership = new createClient({
  api_key: '...' // AfterShip API key.
});

aftership
  .get('couriers')
  .then(console.log)
  .catch(console.error);

aftership
  .post('trackings', {
    tracking: {
      tracking_number: 'RA123456789HK',
      slug: 'usps'
    }
  })
  .then(console.log)
  .catch(console.error);

aftership
  .put('trackings/:slug/:tracking_number', {
    tracking: {
      title: 'New Title'
    }
  })
  .then(console.log)
  .catch(console.error);

Kitchen sink

const aftership = new createClient({
  api_key: '...',
  api_domain: '...',
  version: 'v4',
  headers: {
    // ...
  }
});

Custom headers per request

The API provides you the ability to send various request headers that change the way data is stored or retrieved.

By default this library will encode all data as JSON, however you can customise this by setting your own Content-Type header as an additional argument to get, post, put and delete.

Note: If you add the Content-Type custom header to post, put or delete you will need to encode data yourself.

const aftership = new createClient({
  api_key: '...'
});

const headers = {
  'X-My-Header': 'custom'
};

aftership
  .get('couriers', headers)
  .then(console.log)
  .catch(console.error);

Contact Adam Grohs @ agnoStack for any questions.

Keywords

FAQs

Last updated on 06 Oct 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