1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "requests": [
12 {
13 "url": "https://api.github.com/repos/apify/apify-sdk-js",
14 "method": "GET",
15 "headers": {
16 "Accept": "application/vnd.github+json"
17 }
18 },
19 {
20 "url": "https://httpbin.org/post",
21 "method": "POST",
22 "headers": {
23 "Content-Type": "application/json"
24 },
25 "body": "{\"name\": \"John\", \"email\": \"john@example.com\"}",
26 "bodyType": "json",
27 "auth": {
28 "type": "bearer",
29 "token": "YOUR_TOKEN_HERE"
30 }
31 }
32 ]
33};
34
35
36const run = await client.actor("automation-lab/http-request-builder").call(input);
37
38
39console.log('Results from dataset');
40console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
41const { items } = await client.dataset(run.defaultDatasetId).listItems();
42items.forEach((item) => {
43 console.dir(item);
44});
45
46