Add error handling
This commit is contained in:
@@ -41,8 +41,11 @@ export default class PerudoApi {
|
||||
});
|
||||
}
|
||||
|
||||
private get<T = any>(url: string, getParameters?: Record<string, any>) {
|
||||
private get<T extends ApiObject>(url: string, getParameters?: Record<string, any>): AxiosPromise<T> {
|
||||
return axios.get(url).then((response: AxiosResponse<T>) => {
|
||||
if (response?.data?.errors?.length > 0) {
|
||||
throw response.data.errors?.join();
|
||||
}
|
||||
return response;
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user