Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.get('/', (req, res) => {
- let gamesArr = [];
- axios.get('api1.com/sale')
- .then((response) => {
- gamesArr = response.data.game_discounts; //De este array extraigo un ID que lo paso a la api2
- })
- .catch((error) => {
- console.log(error);
- })
- let openCriticId = [];
- for (let i of gamesArr) {
- if (i.OpenCriticID !== '0' && i.OpenCriticID !== '-1' && i.OpenCriticID !== '-2') {
- axios.get(`https://api.opencritic.com/api/game/${i.OpenCriticID}`)
- .then((response) => {
- openCriticId = [response.data.name, response.data.medianScore];
- })
- .catch((error) => {
- console.log(error);
- })
- }
- }
- console.log(openCriticId); //Este es el array que se retorna vacio
- res.render('inicio', { gamesArr, openCriticId })
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement