确保apify-cli
工具已经更新到最新版本,并重新运行命令
通过输入数据模板来指定输入架构
apify run myactor.js --input '{
"foo": "bar"
}' --build
在这个示例中,被定义为 string
类型的 foo
值被指定为 bar
。
MyFunction
函数,并且该函数已经通过类型检查:async function MyFunction(input) {
const { foo, bar } = input;
if (typeof foo !== 'string') throw new Error('Input property "foo" must be a string!');
if (typeof bar !== 'number') throw new Error('Input property "bar" must be a number!');
console.log(`Hello ${foo}! Your lucky number is ${bar}.`);
}