so I'm pulling in data in express through an external api then outputting it on my page, however, when you navigate to /id it doesn't display the data till after you refresh the page. Any idea on how to fix or why it is causing it to do this?
//gets basic account datas
router.get('/:id', function(req, res, next) {
request('https://na1.api.riotgames.com/lol/summoner/v4/summoners/by-name/'+ req.params.id +'?api_key=RGAPI-05a90f72-a07b-4d8f-bcb3-0a8f938d84ab', { json: true }, (err, res, body) => {
data = body;
data =JSON.stringify(data);
userString = body.id;
console.log(userString);
});
res.send(data);
res.redirect("/"+req.params.id);
});