rework vehicle handling
This commit is contained in:
@@ -15,7 +15,7 @@ async function unwrap<T>(
|
||||
promise: ReturnType<typeof api.get<{ success: boolean; data: T }>>
|
||||
): Promise<T> {
|
||||
const response = await promise;
|
||||
if (!response.data?.data) {
|
||||
if (response.data?.data === undefined || response.data?.data === null) {
|
||||
throw new Error('Invalid API response');
|
||||
}
|
||||
return response.data.data;
|
||||
@@ -47,7 +47,7 @@ export const vehiclesApi = {
|
||||
'/api/vehicles',
|
||||
payload
|
||||
);
|
||||
if (!response.data?.data) {
|
||||
if (response.data?.data === undefined || response.data?.data === null) {
|
||||
throw new Error('Invalid API response');
|
||||
}
|
||||
return response.data.data;
|
||||
@@ -58,7 +58,7 @@ export const vehiclesApi = {
|
||||
`/api/vehicles/${id}`,
|
||||
payload
|
||||
);
|
||||
if (!response.data?.data) {
|
||||
if (response.data?.data === undefined || response.data?.data === null) {
|
||||
throw new Error('Invalid API response');
|
||||
}
|
||||
return response.data.data;
|
||||
@@ -83,7 +83,7 @@ export const vehiclesApi = {
|
||||
`/api/vehicles/${id}/wartung`,
|
||||
payload
|
||||
);
|
||||
if (!response.data?.data) {
|
||||
if (response.data?.data === undefined || response.data?.data === null) {
|
||||
throw new Error('Invalid API response');
|
||||
}
|
||||
return response.data.data;
|
||||
|
||||
Reference in New Issue
Block a user