Create client.js

This commit is contained in:
nune 2024-12-18 16:21:37 -05:00 committed by GitHub
parent fad6b05f9e
commit 1afe2b27bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

17
public/client.js Normal file
View File

@ -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}`;
}
});