0

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?

un1matr1x
  • 23
  • 3
  • any answer would be educational only at this moment. the reason why i thought i need to send smaller data-parts seemed to be wrong and based on false asumtions. – un1matr1x Aug 24 '21 at 19:18
  • This question appears to be about merging objects, but it's impossible to tell what format `data` is in. I'd remove all of the irrelevant info and just show that data structure literal along with the desired result. Thanks. – ggorlen Oct 02 '21 at 22:13

0 Answers0