Hi /r/node,I come to you in a time of need. I'm new to node and all that jazz, and I'm working on a website that allows users to compare stats from League of Legends. So far I've got it all set up and it's making the calls I want. To do this, I'm using express (project set up using express generator) as the back end, and handlebars to display the data. To handle the API I'm using a library called "TeemoJS" .So while my code handles all my API calls/data processing fine, there is a problem with rendering the data on the handlebars page, simply because the data doesn't exist when the page is rendered.Does anyone know how I can delay the rendering of the webpage until all the data exists?Code is as follows (can provide more if its needed): getsummonerID() is the first function called to get data. //GET DATA FROM FORM AND REDIRECT router.post('/summoner/submit', function(req, res, next) { summoner.region = req.body.summRegion; summoner.name = req.body.summName; getsummonerID(); res.redirect('/summoner/lookup'); }); //DATA DISPLAY PAGE router.get('/summoner/lookup', function(req, res, next) { res.render('summoner', { summoner: summoner, title: summoner.name + " on " + summoner.region + " - LOLSTATS.GG", mastery: mastery, rankedInfo: rankedInfo, matches: matches }); }); Thanks :)
Submitted April 05, 2018 at 07:33PM by neeyol
No comments:
Post a Comment