plaster/public/client.js

18 lines
620 B
JavaScript
Raw Normal View History

2024-12-18 21:21:37 +00:00
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}`;
}
});