mirror of
https://github.com/gigirassy/plaster.git
synced 2024-12-24 10:49:07 +00:00
Update client.js
This commit is contained in:
parent
0636b92669
commit
5d12996aec
@ -5,12 +5,13 @@ document.getElementById('fetchBtn').addEventListener('click', async () => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`/fetch-paste?url=${encodeURIComponent(urlInput)}`);
|
const response = await fetch(`/fetch-paste?url=${encodeURIComponent(urlInput)}`);
|
||||||
const data = await response.json();
|
if (!response.ok) {
|
||||||
if (data.error) {
|
const errorData = await response.json(); // Parse error JSON
|
||||||
output.textContent = `Error: ${data.error}`;
|
throw new Error(errorData.error || 'Unknown error occurred');
|
||||||
} else {
|
|
||||||
output.textContent = data.text;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
output.textContent = data.text;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
output.textContent = `Error: ${error.message}`;
|
output.textContent = `Error: ${error.message}`;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user