Skip to content

Commit 1c68faa

Browse files
committed
feat: add code samples for tasks
1 parent b876539 commit 1c68faa

File tree

5 files changed

+40
-0
lines changed

5 files changed

+40
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({ token: 'my-token' });
4+
// Replace apify~my-sample-task with your task's ID or technical name
5+
await apifyClient.task('apify~my-sample-task').delete();
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({ token: 'my-token' });
4+
// Replace apify~my-sample-task with your task's ID or technical name
5+
const task = await apifyClient.task('apify~my-sample-task').get();
6+
7+
console.log(task);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({ token: 'my-token' });
4+
// Replace apify~my-sample-task with your task's ID or technical name
5+
const task = await apifyClient.task('apify~my-sample-task').update({
6+
title: 'New title',
7+
});
8+
9+
console.log(task);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({ token: 'my-token' });
4+
const { items } = await apifyClient.tasks().list();
5+
6+
console.log(items);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { ApifyClient } from 'apify-client';
2+
3+
const apifyClient = new ApifyClient({ token: 'my-token' });
4+
const { items } = await apifyClient.tasks().create({
5+
/**
6+
* Replace apify~my-sample-actor with the ID or technical name
7+
* of the Actor this task will be based on
8+
*/
9+
actId: 'apify~my-sample-actor',
10+
name: 'my-sample-task',
11+
});
12+
13+
console.log(items);

0 commit comments

Comments
 (0)