From 1afe2b27bca40c677b63e9a49a962a3ab15247fb Mon Sep 17 00:00:00 2001 From: nune <145225213+gigirassy@users.noreply.github.com> Date: Wed, 18 Dec 2024 16:21:37 -0500 Subject: [PATCH] Create client.js --- public/client.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 public/client.js diff --git a/public/client.js b/public/client.js new file mode 100644 index 0000000..152f0fa --- /dev/null +++ b/public/client.js @@ -0,0 +1,17 @@ +document.getElementById('fetchBtn').addEventListener('click', async () => { + const urlInput = document.getElementById('pasteUrl').value; + const output = document.getElementById('output'); + output.textContent = 'Loading...'; + + try { + const response = await fetch(`/fetch-paste?url=${encodeURIComponent(urlInput)}`); + const data = await response.json(); + if (data.error) { + output.textContent = `Error: ${data.error}`; + } else { + output.textContent = data.text; + } + } catch (error) { + output.textContent = `Error: ${error.message}`; + } +});