bigreq

A Node.js based HTTP Request client for the BigCommerce API

Usage no npm install needed!

<script type="module">
  import bigreq from 'https://cdn.skypack.dev/bigreq';
</script>

README

BigReq (pronounced "BigRequest")

BigReq is a zero-dependency, Typescript based Node.js HTTP Request client for the BigCommerce API.

Getting Started

First, install using npm or yarn:

npm i bigreq
yarn add bigreq

Then, import BigReq into your file and instantiate the class with your BigCommerce API Credentials:

import BigReq from 'bigreq';
// or
// const BigReq = require('bigreq');

const store = new BigReq({
  ACCESS_TOKEN: 'YOUR API CLIENT ACCESS TOKEN',
  STORE_HASH: 'YOUR STORE HASH',
  CLIENT_ID: 'YOUR API CLIENT ID',
  CLIENT_SECRET: 'YOUR API CLIENT SECRET',
});

store
  .get('/catalog/products')
  .then(data => console.log(data))
  .catch(err => console.error(err));

API

.get(path[, RequestConfig])

.post(path[, RequestConfig])

  • path: A valid BigCommerce API endpoint, following the same format described above.
  • RequestConfig (optional): See RequestConfig
  • Returns: Promise

.put(path[, RequestConfig])

  • path: A valid BigCommerce API endpoint, following the same format described above.
  • RequestConfig (optional): See RequestConfig
  • Returns: Promise

.delete(path[, RequestConfig])

  • path: A valid BigCommerce API endpoint, following the same format described above.
  • RequestConfig (optional): See RequestConfig
  • Returns: Promise

RequestConfig

The RequestConfig object can be passed to any of the request methods above as an optional parameter. These are the aavailable configuration options for making requests:

{
  // (Optional): Either 'v2' or 'v3'. Defaults to 'v3'.
  version: 'v3', // default

  // (Optional): Custom headers to be sent with the request. By
  // default, X-Auth-Token is set automatically for each request.
  headers: {
    Accept: 'application/json', // default
    'Content-Type': 'application/json' // default
  },

  // (Optional): Data to be sent as the request body
  body: {
    some_data: "Test"
  }
}

Contributing

Please read CONTRIBUTING.md