1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "items": [
12 {
13 "person": {
14 "name": "Ada",
15 "age": "42"
16 },
17 "active": "yes",
18 "tags": [
19 "math",
20 "code"
21 ]
22 },
23 {
24 "person": {
25 "name": "Grace",
26 "age": "37"
27 },
28 "active": "true",
29 "tags": [
30 "compiler"
31 ]
32 }
33 ],
34 "mappings": [
35 {
36 "from": "person.name",
37 "to": "name"
38 },
39 {
40 "from": "person.age",
41 "to": "age"
42 },
43 {
44 "from": "active",
45 "to": "active"
46 },
47 {
48 "from": "tags",
49 "to": "tags"
50 }
51 ]
52};
53
54
55const run = await client.actor("eager_vitamin/apify-dataset-flatten-field-mapper").call(input);
56
57
58console.log('Results from dataset');
59console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
60const { items } = await client.dataset(run.defaultDatasetId).listItems();
61items.forEach((item) => {
62 console.dir(item);
63});
64
65