Resolve merge conflict in authStore.ts - use dynamic import for fetchAPI
This commit is contained in:
@@ -193,13 +193,13 @@ export const useAuthStore = create<AuthState>()(
|
||||
}
|
||||
|
||||
try {
|
||||
// Use unified API system - fetchAPI automatically handles auth token from store
|
||||
// Use fetchAPI which handles token automatically and extracts data from unified format
|
||||
// fetchAPI is already imported at the top of the file
|
||||
const response = await fetchAPI('/v1/auth/me/');
|
||||
|
||||
// fetchAPI extracts data from unified format {success: true, data: {user: {...}}}
|
||||
// So response is {user: {...}}
|
||||
|
||||
// fetchAPI extracts data field, so response is {user: {...}}
|
||||
if (!response || !response.user) {
|
||||
throw new Error('Invalid user data received');
|
||||
throw new Error('Failed to refresh user data');
|
||||
}
|
||||
|
||||
// Update user data with latest from server
|
||||
@@ -209,7 +209,7 @@ export const useAuthStore = create<AuthState>()(
|
||||
// If refresh fails, don't logout - just log the error
|
||||
// User might still be authenticated, just couldn't refresh data
|
||||
console.warn('Failed to refresh user data:', error);
|
||||
throw new Error(error.message || 'Failed to refresh user data');
|
||||
// Don't throw - just log the warning to prevent error accumulation
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user