Enhance API response handling and implement unified API standard across multiple modules. Added feature flags for unified exception handling and debug throttling in settings. Updated pagination and response formats in various viewsets to align with the new standard. Improved error handling and response validation in frontend components for better user feedback.
This commit is contained in:
@@ -1114,7 +1114,10 @@ export async function fetchContentImages(filters: ContentImagesFilters = {}): Pr
|
||||
if (filters.sector_id) params.append('sector_id', filters.sector_id.toString());
|
||||
|
||||
const queryString = params.toString();
|
||||
return fetchAPI(`/v1/writer/images/content_images/${queryString ? `?${queryString}` : ''}`);
|
||||
const response = await fetchAPI(`/v1/writer/images/content_images/${queryString ? `?${queryString}` : ''}`);
|
||||
// Extract data field from unified API response format
|
||||
// Response format: { success: true, data: { count: ..., results: [...] }, request_id: "..." }
|
||||
return response?.data || response;
|
||||
}
|
||||
|
||||
export async function bulkUpdateImagesStatus(contentId: number, status: string): Promise<{ updated_count: number }> {
|
||||
@@ -1442,7 +1445,11 @@ export async function fetchUsageSummary(startDate?: string, endDate?: string): P
|
||||
if (endDate) params.append('end_date', endDate);
|
||||
|
||||
const queryString = params.toString();
|
||||
return fetchAPI(`/v1/billing/credits/usage/summary/${queryString ? `?${queryString}` : ''}`);
|
||||
const response = await fetchAPI(`/v1/billing/credits/usage/summary/${queryString ? `?${queryString}` : ''}`);
|
||||
// Extract data field from unified API response format
|
||||
// Response format: { success: true, data: {...}, request_id: "..." }
|
||||
const summaryData = response?.data || response;
|
||||
return summaryData;
|
||||
}
|
||||
|
||||
export interface LimitCard {
|
||||
@@ -1464,7 +1471,10 @@ export async function fetchUsageLimits(): Promise<UsageLimitsResponse> {
|
||||
try {
|
||||
const response = await fetchAPI('/v1/billing/credits/usage/limits/');
|
||||
console.log('Usage limits API response:', response);
|
||||
return response;
|
||||
// Extract data field from unified API response format
|
||||
// Response format: { success: true, data: { limits: [...] }, request_id: "..." }
|
||||
const limitsData = response?.data || response;
|
||||
return limitsData;
|
||||
} catch (error) {
|
||||
console.error('Error fetching usage limits:', error);
|
||||
throw error;
|
||||
|
||||
Reference in New Issue
Block a user