-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
45 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,22 @@ | ||
import axios from '~/utilities/axios'; | ||
import { DashboardConfigKind } from '~/k8sTypes'; | ||
import { AxiosError } from 'axios'; | ||
|
||
export const fetchDashboardConfig = (): Promise<DashboardConfigKind> => { | ||
const url = '/api/config'; | ||
return axios | ||
.get(url) | ||
.then((response) => response.data) | ||
.catch((e) => { | ||
throw new Error(e.response.data.message); | ||
const message = e.response.data?.message; | ||
|
||
// Throw the AxiosError with status code | ||
throw new AxiosError( | ||
message, // Error message from the server | ||
message, // The error message also serves as the "code" argument for AxiosError | ||
undefined, // Optional: request config that was used | ||
e.response, // Optional: the full response object | ||
e | ||
); | ||
}); | ||
}; |