【发布时间】:2018-03-12 11:25:23
【问题描述】:
tl;博士; 发送以下 curl 有效,但我不能在 supertest 中做同样的事情(包装 superagent https://github.com/visionmedia/superagent/)
curl 'http://local/api/items' -X DELETE -H 'Accept-Encoding: gzip, deflate' -H 'content-type: application/json;charset=UTF-8' --data-binary '"1234"'
我可以从网络界面中删除项目,并在其中附加所需文本的文件。
然后使用开发工具提取了上面介绍的 curl 命令,这很有魅力。
如何在js中执行?
试过了:
const response = yield request('http://local')
.delete('/api/items')
.set('Accept-Encoding', 'gzip, deflate')
.set('Content-Type', 'application/json;charset=UTF-8')
.send("1234");
然后我得到
"status":400,"error":"BodyNotReadable",
也许使用write 可以是一个答案,但我不知道该怎么做。
可用选项的完整列表https://github.com/visionmedia/superagent/blob/master/lib/node/index.js
【问题讨论】:
标签: javascript curl request supertest superagent