Socket
Book a DemoInstallSign in
Socket

@agnostack/bigcommerce-request

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@agnostack/bigcommerce-request

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

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

@agnostack/bigcommerce-request

🎮 Minimal BigCommerce API request library for Node

Installation

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

Quickstart (OAuth)

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

const bigcommerce = new createClient({
  store_id: '...', // BigCommerce Store Name.
  client_id: '...', // BigCommercie Client Name.
  access_token: '...', // BigCommerce OAuth token.
});

bigcommerce
  .get('v3/catalog/products')
  .then(console.log)
  .catch(console.error);

bigcommerce
  .post('v3/customers', {
    first_name: 'Jane'
    last_name: 'Doe',
    email: 'johndoe@email.com'
  })
  .then(console.log)
  .catch(console.error);

bigcommerce
  .put('v3/customers', {
    id: 1,
    company: 'Company Name',
    first_name: 'Jane'
    last_name: 'Doe',
    email: 'johndoe@email.com',
    phone: '123456788900'
  })
  .then(console.log)
  .catch(console.error);

Kitchen sink

const bigcommerce = new createClient({
  store_id: '...',
  client_id: '...',
  access_token: '...',
  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, patch, post, put and delete.

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

const bigcommerce = new createClient({
  store_id: '...',
  client_id: '...',
  access_token: '...'
});

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

bigcommerce
  .get('v3/catalog/products', headers)
  .then(console.log)
  .catch(console.error);

Contact Adam Grohs @ agnoStack for any questions.

Keywords

bigcommerce

FAQs

Package last updated on 07 Jan 2020

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