iotx-api-gateway
v1.0.5
Published
Clone From Aliyun API Gateway Node.js SDK
Readme
iotx-api-gateway 网关node sdk
对aliyun-api-gateway进行更新:
- 判断请求是否https,增加httpsAgent;
- 支持传入headers。
Status
Installation
You can install it as dependency with npm/cnpm.
$ # save into package.json dependencies with -S
$ tnpm install iotx-api-gateway -SUsage
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
