forked from phonetonote/phonetonote-logseq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathptn.ts
24 lines (21 loc) · 710 Bytes
/
ptn.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
import { FeedItem } from "ptn-helpers";
export const loadPtnData = async (ptnKey: string): Promise<FeedItem[]> => {
const endpoint = `https://app.phonetonote.com/feed.json?ptn_key=${ptnKey}`;
const data = await fetch(endpoint).then((res) => res.json());
if (data.error) {
throw new Error(`error: ${data.error}`);
}
return data?.items ?? [];
};
export const markItemSynced = async (item, ptnKey) => {
fetch(`https://app.phonetonote.com/feed/${item.id}.json`, {
method: "PATCH",
body: JSON.stringify({
roam_key: `${ptnKey}`,
status: "synced",
}),
headers: {
"Content-type": "application/json; charset=UTF-8",
},
}).then((response) => response.json);
};