mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Signed-off-by: Roman <ixrock@gmail.com> Co-authored-by: Sebastian Malton <sebastian@malton.name> Co-authored-by: Sebastian Malton <smalton@mirantis.com> Co-authored-by: Lauri Nevala <lauri.nevala@gmail.com> Co-authored-by: Alex Andreev <alex.andreev.email@gmail.com>
27 lines
744 B
TypeScript
27 lines
744 B
TypeScript
import { JsonApi, JsonApiErrorParsed } from "./json-api";
|
|
import { KubeJsonApi } from "./kube-json-api";
|
|
import { Notifications } from "../components/notifications";
|
|
import { apiKubePrefix, apiPrefix, isDevelopment } from "../../common/vars";
|
|
|
|
export const apiBase = new JsonApi({
|
|
apiBase: apiPrefix,
|
|
debug: isDevelopment,
|
|
});
|
|
export const apiKube = new KubeJsonApi({
|
|
apiBase: apiKubePrefix,
|
|
debug: isDevelopment,
|
|
});
|
|
|
|
// Common handler for HTTP api errors
|
|
export function onApiError(error: JsonApiErrorParsed, res: Response) {
|
|
switch (res.status) {
|
|
case 403:
|
|
error.isUsedForNotification = true;
|
|
Notifications.error(error);
|
|
break;
|
|
}
|
|
}
|
|
|
|
apiBase.onError.addListener(onApiError);
|
|
apiKube.onError.addListener(onApiError);
|