I have tried a few combinations of the below to no effect. I simply want to pause execution and return to the router function when ready and then release the response. Is this possible?
var express = require('express');
var router = express.Router();
var request = require('request');
router.get('/', function(req, res, next) {
var result = getJson();
res.render('index', { title: result});
});
function *getJson(){
yield request('https://myjson.json', function (error, response, body){
return body;
});
}
module.exports = router;