obniz-cloud-sdk
v2.0.0
Published
[About obniz GraphQL API](https://obniz.com/doc/reference/cloud/cloudapi)
Downloads
135
Readme
obniz-cloud-sdk
を利用するための SDK です。
install
npm i obniz-cloud-sdk
Usage
// Type Script
import { getSdk } from 'obniz-cloud-sdk';
async function getDevices(token: string) {
const obnizAPI = getSdk(token);
const result = await obnizAPI.devices();
for (const edge of result.devices!.edges) {
const obniz = edge!.node!;
console.log(obniz.id);
console.log(obniz.description);
console.log(obniz.osVersion);
console.log(obniz.deviceLiveInfo?.isOnline);
break;
}
}
getDevices("token_XXXXXXXXXX")
// for javascript
const getSdk = require('obniz-cloud-sdk').getSdk;
async function getDevices(token) {
const obnizAPI = getSdk(token);
const result = await obnizAPI.devices();
for (const edge of result.devices.edges) {
const obniz = edge.node;
console.log(obniz.id);
console.log(obniz.description);
console.log(obniz.osVersion);
console.log(obniz.deviceLiveInfo?.isOnline);
break;
}
}
getDevices("token_XXXXXXXXXX")