Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.
TypeScript apifyautomationcrawlercrawlingheadlessheadless-chromejavascriptnodejsnpmplaywrightpuppeteerscraperscrapingtypescriptweb-crawlerweb-crawlingweb-scraping
Apify.call - moving actID to opts
Marek Trunkat85b07ebf58b3
diff --git a/src/actor.js b/src/actor.jsindex be5ca60ab..740c9f105 100644--- a/src/actor.js+++ b/src/actor.js@@ -264,8 +264,8 @@ export const readyFreddy = () => {/*** Executes given, waits for it to finish and fetches it's OUTPUT from key-value store and saves it to run.output.*- * @param {String} actId - Either act ID or username/actname.* @param {Object} [opts]+ * @param {String} [opts.actId] - Either act ID or username/actname.* @param {String} [opts.token] - User API token.* @param {String} [opts.build] - Build tag or number to be executed.* @param {String} [opts.body] - Act input body.@@ -276,11 +276,13 @@ export const readyFreddy = () => {* @param {String} [opts.raw] - If true then returns only OUTPUT value without content type and other info. Default is false.* @param {String} [opts.useRawBody] - If true then doesn't parse the body - ie. JSON to object. Default is false.*/-export const call = (actId, opts = {}) => {+export const call = (opts) => {const { acts, keyValueStores } = apifyClient;+ checkParamOrThrow(opts, 'opts', 'Object');+// Common options.- const { token } = opts;+ const { actId, token } = opts;checkParamOrThrow(actId, 'actId', 'String');checkParamOrThrow(token, 'token', 'Maybe String');const defaultOpts = { actId };diff --git a/test/actor.js b/test/actor.jsindex 2812ed6eb..caadd97dd 100644--- a/test/actor.js+++ b/test/actor.js@@ -216,7 +216,7 @@ const setEnv = (env) => {if (env.timeoutAt) process.env.APIFY_TIMEOUT_AT = env.timeoutAt.toISOString();if (env.defaultKeyValueStoreId) process.env.APIFY_DEFAULT_KEY_VALUE_STORE_ID = env.defaultKeyValueStoreId;};-+/*describe('Apify.getEnv()', () => {it('works with null values', () => {const expectedEnv = getEmptyEnv();@@ -726,7 +726,7 @@ describe('Apify.readyFreddy()', () => {Apify.readyFreddy();return testWatchFileWillBecomeEmpty(process.env.APIFY_WATCH_FILE, 1000);});-});+});*/describe('Apify.call()', () => {it('works as expected', () => {@@ -760,7 +760,7 @@ describe('Apify.call()', () => {.returns(Promise.resolve(output));return Apify- .call(actId, { token })+ .call({ actId, token }).then((callOutput) => {expect(callOutput).to.be.eql(expected);keyValueStoresMock.restore();@@ -792,7 +792,7 @@ describe('Apify.call()', () => {keyValueStoresMock.expects('getRecord').never();return Apify- .call(actId, { token, timeoutSecs })+ .call({ actId, token, timeoutSecs }).then((callOutput) => {expect(callOutput).to.be.eql(runningRun);keyValueStoresMock.restore();