-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
41 lines (31 loc) · 963 Bytes
/
Copy pathtest.js
File metadata and controls
41 lines (31 loc) · 963 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require("dotenv").config();
const { Client } = require("@notionhq/client");
const notion = new Client({
auth: process.env.NOTION_TOKEN,
});
const DATA_SOURCE_ID = process.env.NOTION_DATA_SOURCE_ID;
async function main() {
try {
const response = await notion.dataSources.query({
data_source_id: DATA_SOURCE_ID,
});
console.log("Miembros encontrados:");
console.log("----------------------");
for (const member of response.results) {
const nombre =
member.properties.Nombre?.title?.[0]?.plain_text || "";
const email =
member.properties.Email?.email || "";
const status =
member.properties.Status?.status?.name || "";
console.log(`Nombre: ${nombre}`);
console.log(`Email: ${email}`);
console.log(`Status: ${status}`);
console.log("----------------------");
}
} catch (error) {
console.error("Error:");
console.error(error.message);
}
}
main();