【发布时间】:2017-09-29 14:24:23
【问题描述】:
我有这个 API 调用:
curl -X PATCH --header 'Content-Type: application/json' --header '授权: Bearer 863e2ddf246300f6c62ea9023d068805' -d '1' 'http://asdasd.com/api/loyalty/v1/Accounts/6064361727001553966/Cards'
我想写一个 chai 请求来测试我的 API。 我是这样写的:
describe('/PATCH Patch a card with a Status variable inactive test', () => {
it('it should GET a sample error json response ', (done) => {
chai.request(app)
.patch('/loyalty/v1/cards/6064361727001553966')
.send({"cardStatus": "1" })
.end((err, res) => {
res.should.have.status(200);
done();
});
});
});
但通过这种方式,我传递了“1”值,例如 cardStatus 参数的值。在 API 调用中,我只有这个
-d'1'
如何在 chai 请求中重现此内容? 有没有办法在请求体中传递这个参数而不需要参数key?
【问题讨论】: