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