You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm sure this is something to do with the data cascade that I'm missing, but I'm really stuck on this one.
Data is set up like this:
_data/all_time_club.js
_data/all_time_int.js
_data/all_time.js
The all_time.js file pulls in the data from the other two and then does some calculations.
const int = require('./all_time_int.js');
const club = require('./all_time_club.js');
const playerStatsTotal = async () => {
let statsA = [];
let statsB = [];
club.then(function(c){
console.log(c);
let clubStats = c;
let intStats = int;
let clubStatsA = clubStats[0][0] ? clubStats[0][0]['All Club Competitions'] : '';
let intStatsA = intStats[0][0]['All International Competitions'];
let clubStatsB = clubStats[1][0] ? clubStats[1][0]['All Club Competitions'] : '';
let intStatsB = intStats[1][0]['All International Competitions'];
statsA.push({'All Time Club + Country':{
apps: clubStatsA.apps + intStatsA.apps,
goals: clubStatsA.goals + intStatsA.goals,
assists: clubStatsA.assists + intStatsA.assists,
mins: clubStatsA.mins + intStatsA.mins,
pens: clubStatsA.pens + intStatsA.pens,
pensMissed: clubStatsA.pensMissed + intStatsA.pensMissed,
}})
statsB.push({'All Time Club + Country':{
apps: clubStatsB.apps + intStatsB.apps,
goals: clubStatsB.goals + intStatsB.goals,
assists: clubStatsB.assists + intStatsB.assists,
mins: clubStatsB.mins + intStatsB.mins,
pens: clubStatsB.pens + intStatsB.pens,
pensMissed: clubStatsB.pensMissed + intStatsB.pensMissed,
}})
}).catch((e) => {
console.error(e.message);
})
let stats = [statsA, statsB]
return stats;
}
module.exports = playerStatsTotal();
It all appeared to be working fine, but after pushing live, I realised the section in all-time-stats.njk that uses the all_time.js data was not displaying.
Locally, when I do npm start, the same thing happens. The console.log in the above code returns [ [], [] ]
When I save any .js or .njk file in the project, it all then works.
Does anyone have any idea what the cause of this is and how to fix it?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I'm sure this is something to do with the data cascade that I'm missing, but I'm really stuck on this one.
Data is set up like this:
_data/all_time_club.js
_data/all_time_int.js
_data/all_time.js
The all_time.js file pulls in the data from the other two and then does some calculations.
It all appeared to be working fine, but after pushing live, I realised the section in all-time-stats.njk that uses the all_time.js data was not displaying.
Locally, when I do
npm start, the same thing happens. The console.log in the above code returns[ [], [] ]When I save any .js or .njk file in the project, it all then works.
Does anyone have any idea what the cause of this is and how to fix it?
Any help would be much appreciated!
Beta Was this translation helpful? Give feedback.
All reactions