D
D
Delakey Blackhole2017-04-09 10:40:45
Node.js
Delakey Blackhole, 2017-04-09 10:40:45

Request.post how to prevent object serialization query string?

itemlist is an array of strings;
I send data in this way, but on the receiving side, when deserializing, I get not an array of items, a set of variables "items[1]" "items[2]" items[3]" and so on, how to fix this?
although in another project everything works fine

let data = { steamid: this.gameData.winner.steamid, items: itemlist };
        request.post(
            'http://localhost:4000/senditems',
            { form: {data:data} },
            function (error, response, _body) {
                if (!error && response.statusCode == 200) {
                }
            });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly, 2017-04-09
@vshvydky

Send json if the receiving party is also you, parsing it is not a problem.
Update
In general, the request should change your warm date into a string like steamid=111&items=1&items=2, and in fact, if you correctly accept such data, then this is not a problem either.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question