I have created rest-soap-rest apigee proxy <http://lntorgtest.apigee.net/temperatureconversions/celsiustofahrenheit?nCelsius=37> which calls a soap service to convert temperature from celsius to fahrenheit. This proxy works perfect when I call it in the browser. Now I want to call this proxy from my node.js application. Attached is the node js code. index.txt Is it possible to do this. When i run this code there is no response and gives me unhandled error event.
Is there any npm package i need to install for doing this?
Solved! Go to Solution.
Yes @Saba Sayyed. Try using request module. node-rest-client might be useful for clients, but it doesn't seem to support streaming, so you can't pipe the response to the client. Check your code supporting request module. Hope it helps!
var express = require('express'); var router = express.Router(); var request = require('request'); router.get('/', function(req, res, next) { console.log('Inside index GET router'); request("http://lntorg-test.apigee.net/temperatureconversions/celsiustofahrenheit?nCelsius=37").pipe(res); }); module.exports = router;
Yes @Saba Sayyed. Try using request module. node-rest-client might be useful for clients, but it doesn't seem to support streaming, so you can't pipe the response to the client. Check your code supporting request module. Hope it helps!
var express = require('express'); var router = express.Router(); var request = require('request'); router.get('/', function(req, res, next) { console.log('Inside index GET router'); request("http://lntorg-test.apigee.net/temperatureconversions/celsiustofahrenheit?nCelsius=37").pipe(res); }); module.exports = router;
I would avoid using any external modules, at least to start. Then you have no dependencies to mislead you on errors, etc. Making an http request is straightforward: https://nodejs.org/api/http.html#http_http_request_options_callback
User | Count |
---|---|
2 | |
2 | |
1 | |
1 | |
1 |