1
我正在使用节点js插件: https://www.npmjs.com/package/promise-sequence,我正在尝试的是在调用管道时将参数传递给每个函数。将参数传递给Promise序列
var Nightmare = require('nightmare');
var pipeline = require('promise-sequence/lib/pipeline');
var commonFunctions = require('./websites/_common/commonFunctions')
var nightmare = Nightmare({
show: true,
fullscreen : true,
waitTimeout: 10000
});
var resultsPromise = pipeline([
commonFunctions.accessURL(nightmare),
commonFunctions.loginToWebsite(nightmare),
])
.then(() => commonFunctions.success(nightmare))
.catch((error) => console.log(error));
然而,当我试图传递参数,它给了我一个错误:
TypeError: tasks[0].apply is not a function
at C:\sad\node_modules\promise-sequence\lib\pipeline.js:25:57
at process._tickCallback (internal/process/next_tick.js:103:7)
at Module.runMain (module.js:607:11)
at run (bootstrap_node.js:418:7)
at startup (bootstrap_node.js:139:9)
at bootstrap_node.js:533:3
如何将我的噩梦变量传递给每一个被用作管道参数?
谢谢,它的工作。 – Coder
为什么它不直接工作?为什么需要匿名功能? – Coder
@PHPLover请参阅我在答案中编辑的最后一部分。 –