@thermocline-labs/edge-switch

1.0.2 • Public • Published

edge-switch

EdgeSwitch HTTP client library targeting unofficial JSON endpoints.

npm install @thermocline-labs/edge-switch

Usage

The client instance exposes a promise based interface for communicating with the EdgeSwitch JSON API. All the methods also accept an optional abort signal used to abort the in-flight HTTP request.

const { EdgeSwitch, FetchError, HttpResponseError, AbortError } = require('@thermocline-labs/edge-switch')

const client = EdgeSwitch('localhost', 'username', 'password')

try {
  const abortController = new AbortController()
  const macTable = await client.macTable(abortController.signal)

  console.log(macTable)
} catch (err) {
  if (err instanceof FetchError || err instanceof HttpResponseError) {
    // Handle http error
    return
  }
  if (err instanceof AbortError) {
    // Handle manual abort error
    return
  }

  throw err
}

Package Sidebar

Install

npm i @thermocline-labs/edge-switch

Weekly Downloads

1

Version

1.0.2

License

ISC

Unpacked Size

3.33 kB

Total Files

3

Last publish

Collaborators

  • kapetan