diff --git a/.gitignore b/.gitignore index 3f8e1d990..5e3f66e45 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ +.env node_modules -.vscode/* \ No newline at end of file +.vscode/* +config/.env diff --git a/config/.env b/config/.env deleted file mode 100644 index dbe126e0a..000000000 --- a/config/.env +++ /dev/null @@ -1,2 +0,0 @@ -PORT = 2121 -DB_STRING = mongodb+srv://demo:demo@cluster0.hcds1.mongodb.net/todos?retryWrites=true&w=majority \ No newline at end of file diff --git a/public/js/main.js b/public/js/main.js index b4cfee075..c02db2a2a 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -66,4 +66,21 @@ async function markIncomplete(){ }catch(err){ console.log(err) } -} \ No newline at end of file +} + +document.querySelector('button').addEventListener('click', getFetch) + +function getFetch(){ + const url = 'https://uselessfacts.jsph.pl//random.json?language=en' + + fetch(url) + .then(res => res.json()) + .then(data => { + console.log(data) + document.querySelector('h3').innerText = data.text + document.querySelector('a').innerText = data.source_url + }) + .catch(err => { + console.log(`error ${err}`) + }); +} diff --git a/views/todos.ejs b/views/todos.ejs index d76747a08..84e097132 100644 --- a/views/todos.ejs +++ b/views/todos.ejs @@ -25,6 +25,13 @@ +
+ Logout