Began work on interfacing with the Joplin Data API

This commit is contained in:
Ian Cooperman 2022-08-01 19:00:19 -07:00
parent 49f49112b3
commit a4bfa7dd05

View File

@ -1,8 +1,33 @@
import fetch from 'node-fetch';
import fetch from 'node-fetch'
import 'dotenv/config'
async function main() {
const res = await fetch("https://example.com");
console.log(res.body);
let url = new URL("http://localhost:" + process.env.JOPLIN_CLIPPER_PORT + "/notes")
url.searchParams.append("token", process.env.JOPLIN_TOKEN)
async function getNotes(notebookID) {
let foldersURL = new URL("http://localhost:" + process.env.JOPLIN_CLIPPER_PORT + "/folders/" + process.env.JOPLIN_NOTEBOOK_ID + "/notes")
foldersURL.searchParams.append("token", process.env.JOPLIN_TOKEN)
const res = await fetch(foldersURL.href)
const data = await res.json()
return data
}
const res = main();
async function getNoteData(noteID) {
let noteURL = new URL("http://localhost:" + process.env.JOPLIN_CLIPPER_PORT + "/notes/" + noteID)
const res = await fetch(noteURL.href)
const data = await res.json()
return data
}
getNotes()
.then(res => {
res.items.forEach(element => {
console.log(element.id)
});
})