Tengo TypeError: Cannot read properties of undefined (reading '0') with game_id: result.data[0].game_id, advertencia en mi terminal,
Lo extraño es que el console.log("result ", result); me muestra lo que necesito, pero debajo no puedo acceder a result.data[0].game_id
Código
return promise1.then((result) => { console.log("result ", result); <-- ALL GOOD HERE if (!result && !result.data && !result.data[0]) return; Stream.findOne({}).then((stream) => { if (!stream) { let streamInfos = new Stream({ game_id: result.data[0].game_id, <-- ISSUE HERE Salida de console.log("result ", result);
{"data": [{ "id":"45300981596", "user_id":"90849777", "user_login":"versifixion", "user_name":"VersifiXion", "game_id":"21779", "game_name":"League of Legends", "type":"live", "title":"VERSI | Stream test calculez pas | !reseaux", "viewer_count":1, "started_at":"2022-04-26T21:15:38Z", "language":"fr", "thumbnail_url":"https://static-cdn.jtvnw.net/previews-ttv/live_user_versifixion-{width}x{height}.jpg", "tag_ids":["6f655045-9989-4ef7-8f85-1edcec42d648"], "is_mature":false }], "pagination":{}}