REFACTOR data service
This commit is contained in:
@@ -333,7 +333,12 @@ private buildURL(endpoint: string): string {
|
||||
size: JSON.stringify(result).length,
|
||||
});
|
||||
|
||||
return result;
|
||||
// Handle both wrapped and unwrapped responses
|
||||
// If result has a 'data' property, return it; otherwise return the result itself
|
||||
if (result && typeof result === 'object' && 'data' in result) {
|
||||
return result.data as T;
|
||||
}
|
||||
return result as T;
|
||||
} catch (error) {
|
||||
// Record error metrics
|
||||
this.recordMetrics({
|
||||
|
||||
@@ -7,12 +7,15 @@ export interface RequestConfig {
|
||||
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
||||
headers?: Record<string, string>;
|
||||
params?: Record<string, any>;
|
||||
body?: any;
|
||||
url?: string;
|
||||
timeout?: number;
|
||||
retries?: number;
|
||||
cache?: boolean;
|
||||
cacheTTL?: number;
|
||||
optimistic?: boolean;
|
||||
background?: boolean;
|
||||
metadata?: any;
|
||||
}
|
||||
|
||||
export interface ApiResponse<T = any> {
|
||||
@@ -20,12 +23,14 @@ export interface ApiResponse<T = any> {
|
||||
message?: string;
|
||||
status: string;
|
||||
timestamp?: string;
|
||||
metadata?: any;
|
||||
meta?: {
|
||||
page?: number;
|
||||
limit?: number;
|
||||
total?: number;
|
||||
hasNext?: boolean;
|
||||
hasPrev?: boolean;
|
||||
requestId?: string;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user