M
M
Makcimka2021-03-03 21:17:11
JSON
Makcimka, 2021-03-03 21:17:11

How to pass an array of objects through a query string?

the bottom line is that you need to pass different lengths of the array after making it a string, I rest on the fact that there is only one method that can make a string back into an array on the server, and this is split (
String.prototype.split ())
Punched something like this

const arrData = [
{id: 456239605, count: 4980},
{id: 456239566, count: 9733},
{id: 456239460, count: 15746},
{id: 456239444, count: 18883},
];
 const dataString = arrData.map((elObj)=>{
    return JSON.stringify(elObj)
 }).join('||')
 console.log(dataString);

 console.log(dataString.split('||'));

but the objects remain a string, any ideas?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2021-03-03
@yarkov

JSON.parse

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question