Closed scheng2013 closed 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)); });
同样的接口,调用时beginData可以是YYYY-MM-DD,也可以是YYYY-MM-DD HH:mm:ss,只是后者格式的时候报错。
Service Unavailable 这个是跟接口相关的。具体参数请参考 API 定义,正确传入。
未添加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.