I have the TypeError: Cannot read properties of undefined (reading '0') with game_id: result.data[0].game_id,
warning in my terminal,
What is weird is that the console.log("result ", result);
shows me what I need, but below I can't access result.data[0].game_id
Code
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
Output of the 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":{}}
Via Active questions tagged javascript - Stack Overflow https://ift.tt/8q9zHVK
Comments
Post a Comment