-
Notifications
You must be signed in to change notification settings - Fork 0
/
list-files.ts
51 lines (40 loc) · 1.15 KB
/
list-files.ts
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
42
43
44
45
46
47
48
49
50
51
async function main() {
try {
// Build optional queries
const queryParams = new URLSearchParams();
// Filter by name
//queryParams.append("name", "hello.txt");
// Filter by group ID
// queryParams.append("group", "18893556-de8e-4229-8a9a-27b95468dd3e");
// Filter by mime type
// queryParams.append("mimeType", "text/plain");
// Filter by CID
// queryParams.append(
// "cid",
// "bafkreicnu2aqjkoglrlrd65giwo4l64pdajxffk6jtq2vb7yaiopc3yu7m",
// );
// Set result limit
// queryParams.append("limit", "100");
// Add pagination token
// queryParams.append(
// "pageToken",
// "MDE5MTk0NTctYzJjNi03NzBlLTkzOTEtOGM3MmM0ZjQxZjY0",
// );
const queryString = queryParams.toString();
// Construct the URL
const url = `https://api.pinata.cloud/v3/files${queryString ? `?${queryString}` : ""}`;
// Fetch list of files
const filesRequest = await fetch(url, {
method: "GET",
headers: {
Authorization: `Bearer ${process.env.PINATA_JWT}`,
},
});
// Parse the response and log it out
const files = await filesRequest.json();
console.log(files.data);
} catch (error) {
console.log(error);
}
}
main();