0
我想添加鏈接http.request(url).post(uri)
從chai
NPM模塊摩卡測試feramework。 所以我需要添加field
和attach
的承諾,相信是後只要從一個數組中的值將作爲參數傳遞這些柴方法 如下:如何迭代數組以定義承諾鏈的數量?
var props = ['name:Sara', 'email:[email protected]', 'password:pass'];
var route = '/app/login';
chaiHttp.request(url).post(route)
./* add field promises as much as the array length */
.then(function(res){
// do something with this res
});
我做這樣的事情已經:
var props = ['name:Sara', 'email:[email protected]', 'password:pass'];
var route = '/app/login';
chaiHttp.request(url).post(route).field('name','Sara').field('email','[email protected]').then(function(res){
//do something with response
});
你試過了一個循環嗎?或'props.reduce'? – Bergi
是的,我也嘗試了一些從這裏解決方案http://stackoverflow.com/questions/17757654/how-to-chain-a-variable-number-of-promises-in-q-in-order – SAlidadi
它並沒有'工作?爲什麼?請[編輯]您的問題以包括這些嘗試,以便我們可以指導您。 – Bergi