gpt4 book ai didi

javascript - 在 Supertest 上使用 PUT 方法

转载 作者:行者123 更新时间:2023-11-28 20:22:28 24 4
gpt4 key购买 nike

如何在 SuperTest 中使用 PUT 方法?我得到的只是“404 Not found”作为响应。

请求处理程序:

router.put('/', function (req, res) {
res.type('json');

FooResource(req.body, function () {
res.send("{}");
});
});

测试套件:

describe("PUT /foo/fii", function () {

it("Respond with 200", function (done) {

request(app)
.put('/')
.set('Accept', 'application/json')
.expect(200, done);

});
});

最佳答案

添加:

    it("Respond with 200", function (done) {

request(app)
.put('/')
.send("{}")
.expect(200)
.end(function(err, res) {
done();
})

});

现在可以用了(?)

关于javascript - 在 Supertest 上使用 PUT 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42608696/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com