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)}`);
|
2024-12-18 21:47:55 +00:00
|
|
|
if (!response.ok) {
|
|
|
|
const errorData = await response.json(); // Parse error JSON
|
|
|
|
throw new Error(errorData.error || 'Unknown error occurred');
|
2024-12-18 21:21:37 +00:00
|
|
|
}
|
2024-12-18 21:47:55 +00:00
|
|
|
|
2024-12-18 21:53:26 +00:00
|
|
|
const text = await response.text(); // Always plain text
|
|
|
|
output.textContent = text; // Display raw text
|
2024-12-18 21:21:37 +00:00
|
|
|
} catch (error) {
|
|
|
|
output.textContent = `Error: ${error.message}`;
|
|
|
|
}
|
|
|
|
});
|