I'm writing a small userscript to recieve an object from a xhr request and send parts of it to another website. The recieved json looks like this
{"result": [
{"id":"1234","title":"Gartenzwerg","description":"Strom unter Kunst","lat":153.558356,"lng":50.205637,"city":"Citü","state":"XY","day":"1970-01-01","order":0,"imageUrl":"https://cool.page","nextUpgrade":false,"upgraded":false,"status":"WITHDRAWN"},
{"id":"56789","title":"Weizenähre","description":"Strom unter Kunst","lat":153.590972,"lng":50.235216,"city":"Citü","state":"XY","day":"1971-01-01","order":1,"imageUrl":"https://cooler.page","nextUpgrade":true,"upgraded":true,"status":"NOMINATED"},
{...}],
"message":null,
"code":"OK",
"errorsWithIcon":null,
"fieldErrors":null,
"errorDetails":null,
"version":"4.0.10",
"captcha":false}
I use Add a "hook" to all AJAX requests on a page to get the informations and then send each result-part by it's own to my page with a fetch-function
var data = JSON.parse(this.responseText).result;
for (let i=0; i<Object.keys(data).length; i++) {
sendDataToPage(data[Object.keys(data)[i]]);
await sleep(500);
}
Now it's very ineffective to send each by it's own, so i'd like to groupe f.e. 10 elements before I send them. With Object.assign
I only get the last element. Do I have to use another function to merge or how do I use it the right way?