SDK Installation
Last Updated:2020-07-20
Version Detection
$ npm -v
// Check if npm is installed correctly$ node -v
// Check node version
Versions That Support Node.js
- 4.x
- 5.x
Install the SDK
The JavaScript package has been uploaded to the npm manager to install the SDK's development package directly using npm.
npm install @baiducloud/sdk
Then use it in the program:
import {TsdbDataClient} from '@baiducloud/sdk';
// use babel to escape to require keyword
// or use var TsdbDataClient = require('@baiducloud/sdk').TsdbDataClient;
const config = {
endpoint: <Endpoint>, // user's time series database domain name, with the format such as http://{databaseName}.tsdb.iot.gz.baidubce.com
credentials: {
ak: <AccessKeyID>, //your AccessKey
sk: <SecretAccessKey> //your SecretAccessKey
}
};
let client = new TsdbDataClient(config);
client.getMetrics() // call the needed interface
.then(response => console.log(response)) // successful
.catch(error => console.error(error)); // failed