the array bellow (query.conditions) gets converted to an object somehow, any idea why and how I can prevent it ?
The request:
supertest(options.url)
.get('/api/action')
.expect(200)
.query({
conditions:
[
{ 'user' : user._id },
{ 'type' : 14 },
{ 'what' : 4 },
]
})
What the server gets:
{
"conditions": {
"user": "5592cc851f3febd016dae920",
"type": "14",
"what": "4"
}
}
There seem to be issues with query string serialization in superagent
(which is used by supertest
).
To work around that, you can use qs.stringify()
on your data:
var qs = require('qs');
...
supertest(options.url)
.get('/api/action')
.expect(200)
.query(qs.stringify({
conditions:
[
{ 'user' : user._id },
{ 'type' : 14 },
{ 'what' : 4 },
]
}))
(if at all possible, it might be more appropriate to POST JSON instead, though)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With