4
我正在使用node.js構建應用程序並使用mocha + chai進行測試。有沒有一種方法可以將自定義標題添加到我的GET和POST chai請求中?向chai請求添加自定義http標題
例如,我想是這樣的(半僞代碼):
chai.request(server)
.get('/api/car/' + data.car_id)
.headers({'some_custom_attribute':'some_value'})
.end(function(err, res) {
//do something
});
而且同樣與崗位:
chai.request(server)
.post('/api/car/')
.headers({'some_custom_attribute':'some_value'})
.send({car_id: 'some_car_id'})
.end(function(err, res) {
//do something
});
有人能幫忙嗎?
在此先感謝!
以及如何與標題一起添加後的變量? – user269867
@ user269867使用'send'方法。 – alexmac