I am trying to extract the number of goals from the retrieved json data shown in my appsscript log below:
Info {copyright=NHL and the NHL Shield are registered trademarks of the National Hockey League. NHL and NHL team marks are the property of the NHL and its teams. © NHL 2021. All Rights Reserved., stats=[{splits=[{season=20202021, stat={pim=4.0, faceOffPct=0.0, plusMinus=3.0, blocked=1.0, shifts=69.0, penaltyMinutes=4, shots=10.0, shortHandedTimeOnIcePerGame=01:59, shotPct=10.0, games=3.0, shortHandedTimeOnIce=05:59, shortHandedGoals=0.0, gameWinningGoals=0.0, overTimeGoals=0.0, powerPlayTimeOnIcePerGame=02:51, powerPlayTimeOnIce=08:34, timeOnIcePerGame=17:31, assists=2.0, timeOnIce=52:33, evenTimeOnIce=38:00, powerPlayPoints=0.0, shortHandedPoints=0.0, evenTimeOnIcePerGame=12:40, goals=1.0, powerPlayGoals=0.0, points=3.0, hits=3.0}}], type={gameType={id=R, description=Regular season, postseason=false}, displayName=statsSingleSeason}}]}
the appscript code i have used is:
function update() {
var response = UrlFetchApp.fetch("https://statsapi.web.nhl.com/api/v1/people/8473986/stats?stats=statsSingleSeason&season=20202021");
var json = response.getContentText();
var data = JSON.parse(json);
Logger.log(data);
Logger.log(data.stats.goals);
}
how can I log the goals from the data shown in the apps script log image (above)?
thanks for the help!