apigee - Node.js:Unable to invoke pipe function -
i trying out simple program invoke call backend & response back, here node.js code:
'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); };
however following error:
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 @ summary (c:\apigee127\api-116\api\controllers\summary.js:17:19) @ swaggerrouter (c:\apigee127\api-116\node_modules\a127-magic\node_modules\ swagger-tools\middleware\2.0\swagger-router.js:114:18) @ c:\apigee127\api-116\node_modules\a127-magic\lib\middleware.js:82:9 ....
is there npm package missing need download?
-s
you breaking scoping. function takes request
have loaded var request = require('request')
.
change such have:
var request = require('request'); function summary(req, res) { request.get(url).pipe(res); }
Comments
Post a Comment