我正在尝试一个简单的程序来调用后端并获取响应,这是我的 node.js 代码:
'use strict';
var util = require('util');
var http = require('http');
var request = require('request');
var stream = require('stream');
module.exports = {
summary:summary
}
function summary(request, response) {
var id = request.swagger.params.id.value;
var url = "http://localhost:8080/test-org/myApp/summaries?q='id'";
console.log('Executing request: '+url);
request.get(url).pipe(response);
};
但是我收到以下错误:
curl http://localhost:10010/v1/customers/1123/summary
Executing request: http://localhost:8080/test-org/myApp/summaries?q='
id'
TypeError: Cannot call method 'pipe' of undefined
at summary (C:\Apigee127\API-116\api\controllers\summary.js:17:19)
at swaggerRouter (C:\Apigee127\API-116\node_modules\a127-magic\node_modules\
swagger-tools\middleware\2.0\swagger-router.js:114:18)
at C:\Apigee127\API-116\node_modules\a127-magic\lib\middleware.js:82:9
....
是否有一些我需要下载的 npm 包?
-S