-
Notifications
You must be signed in to change notification settings - Fork 0
/
list-files.ts
48 lines (37 loc) · 1.1 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
async function main() {
try {
// Build optional queries
const queryParams = new URLSearchParams({ status: "pinned" });
// Filter by name
//queryParams.append("metadata[name]", "hello.txt");
// Filter by group ID
// queryParams.append("groupId", "18893556-de8e-4229-8a9a-27b95468dd3e");
// Filter by mime type
// queryParams.append("mimeType", "text/plain");
// Filter by CID
//queryParams.append("cid", "QmVLwvmGehsrNEvhcCnnsw5RQNseohgEkFNN1848zNzdng");
// Set result limit
//queryParams.append("pageLimit", "100");
// Add pagination
// queryParams.append(
// "pageOffset",
// "100",
// );
const queryString = queryParams.toString();
// Construct the URL
const url = `https://api.pinata.cloud/data/pinList${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.rows);
} catch (error) {
console.log(error);
}
}
main();