Socket
Socket
Sign inDemoInstall

@nrfcloud/api-client-javascript

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nrfcloud/api-client-javascript

JavaScript API client for the nRFCloud.com REST API


Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

nRF Cloud JavaScript API Client

npm preview version Build Status Test Coverage
Greenkeeper badge semantic-release
Commitizen friendly
DeepScan Grade Known Vulnerabilities Maintainability

Provides the JavaScript API client for the nRFCloud.com REST API.

:warning: This is a preview release and might be changed without notice.

API Client

The API client is available on npm:

npm i @nrfcloud/api-client-javascript@preview

You also need to install the updated models.

npm i @nrfcloud/models@next

Browser

const {Client} = require('@nrfcloud/api-client-javascript')

const client = new Client(token);
client
  .registerGateway('foo')
  .then(res => {
      console.log(res)
  })

Node.js

npm i isomorphic-fetch es6-promise
require('es6-promise').polyfill()
require('isomorphic-fetch')

const {Client} = require('@nrfcloud/api-client-javascript')

...

Testing with the API client

A testing API Gateway can provide an /token endpoint which returns a Cognito User Pool Identity Token so it is not required to use the AWS Cognito SDK.

Example:

npm i @nrfcloud/api-client-javascript@preview @nrfcloud/models@next isomorphic-fetch es6-promise
require('es6-promise').polyfill();
require('isomorphic-fetch');
const { Client } = require('@nrfcloud/api-client-javascript');

const endpoint = 'https://1ewo2b2jmj.execute-api.us-east-1.amazonaws.com/dev';
const username = 'changeme'; // nrfcloud.com email
const password = 'changeme';

(async () => {

   // This is an undocumented endpoint, which will only be on dev / test stages
   const res = await fetch(`${endpoint}/token`, {
      method: 'POST',
      body: JSON.stringify({ username, password })
   });
   const { token } = await res.json();

   // Construct a client
   const client = new Client(token, endpoint);
   client
      .listTenants('true')
      .then(([{ id }]) => client.registerGateway(id))
      .then(res => {
         console.log(res)
      })
      .catch(err => {
         console.error(err)
      })
})();

Keywords

FAQs

Package last updated on 09 Mar 2018

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc