1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-30 04:23:11 +03:00

JS: Converted http service to ts

This commit is contained in:
Dan Brown
2024-07-18 15:13:14 +01:00
parent 634b0aaa07
commit fb87fb5750
6 changed files with 234 additions and 244 deletions

View File

@ -1,3 +1,5 @@
import {HttpError} from "./http";
export class EventManager {
protected listeners: Record<string, ((data: {}) => void)[]> = {};
protected stack: {name: string, data: {}}[] = [];
@ -62,9 +64,9 @@ export class EventManager {
/**
* Notify standard server-provided error messages.
*/
showResponseError(responseErr: {status?: number, data?: {message?: string}}): void {
showResponseError(responseErr: {status?: number, data?: Record<any, any>}|HttpError): void {
if (!responseErr.status) return;
if (responseErr.status >= 400 && responseErr.data && responseErr.data.message) {
if (responseErr.status >= 400 && typeof responseErr.data === 'object' && responseErr.data.message) {
this.error(responseErr.data.message);
}
}