mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-04-14 16:40:58 -04:00
Proper error handling for creating a link without internet (#577)
* Proper error handling for creating a link without internet * shuffle code a bit Co-authored-by: David Luzar <luzar.david@gmail.com>
This commit is contained in:
parent
1d9cdf4d46
commit
4b0f788945
1 changed files with 23 additions and 17 deletions
|
@ -144,7 +144,9 @@ export async function exportToBackend(
|
||||||
elements: readonly ExcalidrawElement[],
|
elements: readonly ExcalidrawElement[],
|
||||||
appState: AppState,
|
appState: AppState,
|
||||||
) {
|
) {
|
||||||
const response = await fetch(BACKEND_POST, {
|
let response;
|
||||||
|
try {
|
||||||
|
response = await fetch(BACKEND_POST, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: serializeAsJSON(elements, appState),
|
body: serializeAsJSON(elements, appState),
|
||||||
|
@ -164,6 +166,10 @@ export async function exportToBackend(
|
||||||
} else {
|
} else {
|
||||||
window.alert(i18n.t("alerts.couldNotCreateShareableLink"));
|
window.alert(i18n.t("alerts.couldNotCreateShareableLink"));
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
window.alert(i18n.t("alerts.couldNotCreateShareableLink"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function importFromBackend(id: string | null) {
|
export async function importFromBackend(id: string | null) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue