]> BookStack Code Mirror - bookstack/blobdiff - resources/js/services/drawio.ts
JS: Converted http service to ts
[bookstack] / resources / js / services / drawio.ts
index 75b161f75d5c2c57150e5c252cc9fce82c5399ae..c0a6b5044bc6256639abd691d5df52d617b1a1b3 100644 (file)
@@ -1,6 +1,7 @@
 // Docs: https://www.diagrams.net/doc/faq/embed-mode
 import * as store from './store';
 import {ConfirmDialog} from "../components";
+import {HttpError} from "./http";
 
 type DrawioExportEventResponse = {
     action: 'export',
@@ -145,9 +146,10 @@ export function close() {
 export async function load(drawingId: string): Promise<string> {
     try {
         const resp = await window.$http.get(window.baseUrl(`/images/drawio/base64/${drawingId}`));
-        return `data:image/png;base64,${resp.data.content}`;
+        const data = resp.data as {content: string};
+        return `data:image/png;base64,${data.content}`;
     } catch (error) {
-        if (error instanceof window.$http.HttpError) {
+        if (error instanceof HttpError) {
             window.$events.showResponseError(error);
         }
         close();