// works on script of a page // async function getGameData() // { // return await fetch('https://127.0.0.1:2999/GetLiveclientdataAllgamedata', // { // method:"GET", // mode:"cors", // headers: // { // "Access-Control-Allow-Methods": "*" // } // }).then(handleRes).catch(handleFailure) // async function handleRes(res) // { // console.log(res) // return await res.json(); // } // function handleFailure() // { // return 'Failed to fetch' // } // } // setInterval(async () => { // console.log(await getGameData()) // }, 1000); // var skinURL = `http://ddragon.leagueoflegends.com/cdn/img/champion/splash/${championName}_${skinID}.jpg`; var coiso = [ { "championName": "Caitlyn", "scores": { "creepScore": 100, "deaths": 0, "kills": 8, }, "skinID": 20, "summonerName": "hc12", "summonerSpells": { "summonerSpellOne": { "displayName": "Barrier", }, "summonerSpellTwo": { "displayName": "Flash", } }, "team": "ORDER" }, { "championName": "Lux", "scores": { "assists": 0, "creepScore": 10, "deaths": 8, "kills": 0, }, "skinID": 0, "summonerName": "Lux Bot", "summonerSpells": { "summonerSpellOne": { "displayName": "Heal", }, "summonerSpellTwo": { "displayName": "Exhaust", } }, "team": "CHAOS" } ] var events = [ [ { "EventID": 0, "EventName": "GameStart", "EventTime": 0.04342550039291382 }, { "EventID": 1, "EventName": "MinionsSpawning", "EventTime": 65.07691955566406 }, { "EventID": 3, "EventName": "FirstBlood", "EventTime": 209.65553283691406, "Recipient": "hc12" }, { "EventID": 16, "EventName": "FirstBrick", "EventTime": 605.8714599609375, "KillerName": "hc12" } ] ] var id = 'coiso' var a = { coiso: [ { gId:'coiso' }, { gId: 'coisa' } ] } var replacement = {gId:'coisada'} const index = a.coiso.findIndex(x=>x.gId=id); a.coiso[index] = replacement; console.log(a.coiso) var b = { _id: new ObjectId("642359f907f5cbd1bfba7646"), Players: [ { Name: 1, Points: 2, PlayedPoints: 0, Kills: 2, Deaths: 0, CreepScore: 0, PointsPlayed: NaN }, { Name: 'Ezreal Bot', Points: 0, PlayedPoints: 0, Kills: 0, Deaths: 0, CreepScore: 0 } ], Games: [ { _id: new ObjectId("642359f907f5cbd1bfba7642"), Winner: 'hc12', WinCondition: 'FirstBlood', Played: true, PlayedTimeStamp: '1680125543862', __v: 0 }, { PA: [Object], PB: [Object], Winner: '', WinCondition: '', Played: false, PlayedTimeStamp: '', gId: '642359f907f5cbd1bfba7642' } ], Name: 'test', Owner: '186540961650835456', __v: 0 }