Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wangjunzzz/api-gateway
阿里云网关Node.js Sdk包
https://github.com/wangjunzzz/api-gateway
Last synced: 5 days ago
JSON representation
阿里云网关Node.js Sdk包
- Host: GitHub
- URL: https://github.com/wangjunzzz/api-gateway
- Owner: WangJunZzz
- License: mit
- Created: 2019-11-28T07:04:53.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-12-06T18:16:50.000Z (about 2 years ago)
- Last Synced: 2024-12-20T09:10:33.585Z (about 1 month ago)
- Language: JavaScript
- Size: 333 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: MIT-License
Awesome Lists containing this project
README
Aliyun API Gateway SDK for Node.js Pro
## Installation
>原来的阿里云的node.js网关的sdk依赖于httpx模块,在vue项目中使用会有小问题
>把httpx 修改为 api-gateway-httpx(只发布在Npm官网)```sh
$ # save into package.json dependencies with -S
$ npm install api-gateway-http -S
```## Usage
The SDK contains Simple client(authrozied by appcode) and Normal client(authrozied by appid & appsecret).
### Simple client
```js
'use strict';const SimpleClient = require('aliyun-api-gateway').SimpleClient;
const client = new SimpleClient('YOUR_APP_CODE');async function post() {
var url = 'http://apiqingdaohttps.foundai.com/test1234';var result = await client.post(url, {
data: {
'testtest': 'query1Value'
},
headers: {
accept: 'application/json'
}
});console.log(JSON.stringify(result));
}post().catch((err) => {
console.log(err.stack);
});
```### Client (recommend)
```js
'use strict';const Client = require('aliyun-api-gateway').Client;
const client = new Client('YOUR_APP_KEY','YOUR_APP_SECRET');async function post() {
var url = 'http://apiqingdaohttps.foundai.com/test1234';var result = await client.post(url, {
data: {
'testtest': 'query1Value'
},
headers: {
accept: 'application/json'
}
});console.log(JSON.stringify(result));
}post().catch((err) => {
console.log(err.stack);
});
```## Question?
Please submit an issue.