1.0.5 • Published 5 years ago
iotx-api-gateway v1.0.5
iotx-api-gateway 网关node sdk
对aliyun-api-gateway进行更新: 1. 判断请求是否https,增加httpsAgent; 2. 支持传入headers。
Status
Installation
You can install it as dependency with npm/cnpm.
$ # save into package.json dependencies with -S
$ tnpm install iotx-api-gateway -S
Usage
The SDK contains Simple client(authrozied by appcode) and Normal client(authrozied by appid & appsecret).
Simple client
'use strict';
const co = require('co');
const SimpleClient = require('iotx-api-gateway').SimpleClient;
const client = new SimpleClient('YOUR_APP_CODE');
co(function* () {
var url = 'http://apiqingdaohttps.foundai.com/test1234';
var result = yield client.post(url, {
data: {
'testtest': 'query1Value'
},
headers: {
accept: 'application/json'
}
});
console.log(JSON.stringify(result));
});
Client (recommend)
'use strict';
const co = require('co');
const Client = require('iotx-api-gateway').Client;
const client = new Client('YOUR_APP_KEY','YOUR_APP_SECRET');
co(function* () {
var url = 'http://apiqingdaohttps.foundai.com/test1234';
var result = yield client.post(url, {
data: {
'testtest': 'query1Value'
},
headers: {
accept: 'application/json'
}
});
console.log(JSON.stringify(result));
});
Question?
Please submit an issue.
License
The MIT License