-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.ts
38 lines (30 loc) · 1.01 KB
/
example.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
import { Raindrop, RaindropItem } from "../index";
const raindroip_token = process.env.RAINDROP_TOKEN || "";
const raindrop_collection_id = process.env.RAINDROP_COLLECTION_ID || "";
if (!raindroip_token || !raindrop_collection_id) {
throw new Error(
"Please provide RAINDROP_TOKEN and RAINDROP_COLLECTION_ID environment variables.",
);
}
const raindrop = new Raindrop(raindroip_token);
const item: RaindropItem = {
title: "This is a title",
link: "https://www.google.com",
note: "This is a note.",
collection: {
$id: Number(raindrop_collection_id),
},
};
raindrop.addItem(item).then((result) => {
console.log("addItem:", result);
raindrop.getFirstItemFromCollection(raindrop_collection_id).then((result) => {
console.log("getFirstItemFromCollection:", result);
const itemId = result.object._id;
if (!itemId) {
throw new Error("No item found in collection.");
}
raindrop.removeItem(itemId.toString()).then((result) => {
console.log("removeItem:", result);
});
});
});