javascript - express node.js making a get request to another server from node route -


so client makes request using button on index page. sends information route has been set follows:

app.js

var route = require('./routes/index'); var button = require('./routes/button'); app.use('/', index); app.use('/button', button); 

the request sent client-side directory node framework whenever presses button. if request sent 'localhost:port/button', button.js file mentioned above receive request. in button.js file have following:

var express = require('express'); var router = express.router(); var somedata = '';  router.get('/', function (req, res, next) {     //make request here such somedata     //receives whatever request returns     //set framework(i.e. spring...)     somedata = getrequest('some other url');     res.send(somedata); }; module.exports = router; 

the problem here getrequest('some other url') within router request never receives information.

also (as side-note), cannot seem find in express api why have

router.get('/')... 

instead of

router.get('/button')... 

to access , make requests button page.

any appreciated!

you want make request other rest api running somewhere else right? can use node-rest-client that.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -