From 8e35036e468722aa849ddd00317baa0583a9bbf3 Mon Sep 17 00:00:00 2001 From: nune <145225213+gigirassy@users.noreply.github.com> Date: Wed, 18 Dec 2024 16:57:23 -0500 Subject: [PATCH] Update client.js --- public/client.js | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/public/client.js b/public/client.js index d834210..46ced75 100644 --- a/public/client.js +++ b/public/client.js @@ -1,18 +1,7 @@ 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)}`); - if (!response.ok) { - const errorData = await response.json(); // Parse error JSON - throw new Error(errorData.error || 'Unknown error occurred'); - } - - const text = await response.text(); // Always plain text - output.textContent = text; // Display raw text - } catch (error) { - output.textContent = `Error: ${error.message}`; - } + // Perform a redirection by using the input URL directly + const redirectUrl = `/fetch-paste?url=${encodeURIComponent(urlInput)}`; + window.location.href = redirectUrl; // This redirects the user to the raw paste URL });