Reputation: 314
I am trying to make a get request to a simple website, and display the "phrase"'s value
here is what i have for index.js
router.get('https://corporatebs-generator.sameerkumar.website/', function(req, res, next) {
res.render({corporateMessage :req.query});
});
router.get('/', function (req, res, next) {
res.render('index', { title: 'The corp'});
})
Here is what i have for my index.hbs
<h1>{{title}}</h1>
<p> {{corporateMessage}}</p>
I just want to be able to display the message thats in the 'phrase', and have it shown in the above html format, not sure what to put in the req.query
part.. little confused
Upvotes: 0
Views: 224
Reputation: 81
You can use request
to get the response from external path like this:
var request = require('request');
router.get('/path', function(req, res){
request({url: 'https://corporatebs-generator.sameerkumar.website/', json: true}, function (error, response, body) {
res.render('index', {
corporateMessage: body.phrase
})
});
})
Upvotes: 1