数组无意中被转换为超级对象
数组波纹pipe(query.conditions)以某种方式转换为对象,任何想法为什么以及如何防止它?
请求:
supertest(options.url) .get('/api/action') .expect(200) .query({ conditions: [ { 'user' : user._id }, { 'type' : 14 }, { 'what' : 4 }, ] })
服务器得到什么:
{ "conditions": { "user": "5592cc851f3febd016dae920", "type": "14", "what": "4" } }
superagent
查询string序列化似乎存在问题 (由supertest
)。
要解决这个问题,你可以在你的数据上使用qs.stringify()
:
var qs = require('qs'); ... supertest(options.url) .get('/api/action') .expect(200) .query(qs.stringify({ conditions: [ { 'user' : user._id }, { 'type' : 14 }, { 'what' : 4 }, ] }))
(如果可能的话,可能更适合于POST JSON)
- 通过github API复制版本库
- 获取https响应的正文
- 如何用微服务架构devise一个sails.js项目?
- 即使在安装了bower组件之后,即使安装了git和pathvariables之后,也没有安装“Git not installed or path not specified”
- StyleDocco输出文档确实应用了CSS
- 元素不可点击Selenium webdriver
- 我不断收到在Eclipse上运行Grunt的“env:node:没有这样的文件或目录”,作为MacOS Yosemite下的外部工具
- 从ReadableStream对象中检索数据?
- socket.io使用for循环来添加socket.on方法