我得到了以下错误,
Error: Error parsing JSON string: Unexpected token <
Given: <html>
<body>
<p>
<b>400.</b> Invalid json request: numOfDays=1&checkInDate=2013-04-10.
Make sure that key names and text values are quoted with "
</p>
</body>
</html>
Stacktrace:使用以下代码:
var frisby = require('frisby');
frisby.create('Ensure proper values in specified keys')
.post('http://localhost:9090/bookRoom', {"numOfDays": 1 , "checkInDate":"2013-04-10"})
.expectJSON({
"checkInDate": "2013-04-10",
"checkOutDate": "2013-04-11",
"totalPrice": 130
})
.toss()我正在尝试传递这个JSON - {"numOfDays":1,"checkInDate":"2013-04-10"}
编辑:
传递的JSON似乎采用以下格式。我怎么去掉那些反斜杠?
Handling booking request: "{\"numOfDays\":\"1\",\"checkInDate\":\"2013-04-10\"}"发布于 2015-01-07 00:08:22
Frisby.js的作者在这里。请更新到Frisby v0.8.5 -这是由于Frisby依赖和使用的"request“模块发生了变化。
发布于 2015-01-03 18:50:33
我刚刚遇到了同样的问题,但我对post使用了不同的参数。准确地说,我添加了{json: true}作为第三个参数,经过几分钟的努力,我删除了它,它起作用了。
看起来你的情况可能正好相反。尝试将第三个参数放在post方法调用中,并希望是最好的。
相关文档:API docs
https://stackoverflow.com/questions/27427895
复制相似问题