aliyun / api-gateway-nodejs-sdk

The API Gateway SDK for Node.js
MIT License
106 stars 23 forks source link

调用接口返回异常如下(用其他开发语言都可以正确调用) #17

Closed scheng2013 closed 6 years ago

scheng2013 commented 6 years ago

未添加timeout bogon:src scheng$ node mhttp.js (node:9271) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): RequestTimeoutError: POST http://api.winneryun.com/huikeportal/PassengerFlowData/getDataByDataDate timeout(3000). POST http://api.winneryun.com/huikeportal/PassengerFlowData/getDataByDataDate failed. (node:9271) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

添加timeout:30000 bogon:src scheng$ node mhttp.js (node:9272) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: POST http://api.winneryun.com/huikeportal/PassengerFlowData/getDataByDataDate failed width code(503). request id: 52917C03-054A-48F4-864B-44A1EA06A415, error message: Service Unavailable (node:9272) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

scheng2013 commented 6 years ago

'use strict'; const co = require('co'); const Client = require('aliyun-api-gateway').Client; const client = new Client('**','***');

co(function* () { var url = 'http://api.winneryun.com/huikeportal/PassengerFlowData/getDataByDataDate';

var result = yield client.post(url, { data: { "customerId": "", "beginDate": "2017-12-10 08:00:00", "endDate": "2017-12-11 09:00:00", "interval": "" }, headers: { accept: 'application/json' }, timeout:30000 });

console.log(JSON.stringify(result)); });

scheng2013 commented 6 years ago

同样的接口,调用时beginData可以是YYYY-MM-DD,也可以是YYYY-MM-DD HH:mm:ss,只是后者格式的时候报错。

JacksonTian commented 6 years ago

Service Unavailable 这个是跟接口相关的。具体参数请参考 API 定义,正确传入。