diff --git a/joplin.js b/joplin.js index a77b8f6..9b2aa95 100644 --- a/joplin.js +++ b/joplin.js @@ -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(); \ No newline at end of file +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) + }); + }) \ No newline at end of file