1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "input": `// Available packages:
12// - Apify Actor - https://docs.apify.com/sdk/js/reference/class/Actor
13// - example:
14// await Actor.pushData({ my : 'data'});
15// - Axios - https://axios-http.com/
16// - example:
17// log.info(`Current IP is: ${(await Axios.get('https://ipinfo.io/json')).data.ip}`)
18// - Moment.js - https://momentjs.com/
19// - example:
20// log.info(`Tomorrow is: ${moment().add(1, 'day').toISOString()}`)
21
22const waitTime = Math.ceil(5 + Math.random() * 10);
23
24return {
25 minWaitTime: waitTime,
26 maxWaitTime: waitTime + 2_000
27}`,
28 "proxyConfiguration": {
29 "useApifyProxy": true
30 }
31};
32
33
34const run = await client.actor("useful-tools/dynamic-input").call(input);
35
36
37console.log('Results from dataset');
38console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
39const { items } = await client.dataset(run.defaultDatasetId).listItems();
40items.forEach((item) => {
41 console.dir(item);
42});
43
44