fix(mobile): fix authorization API response parsing

The API returns {"success": true, "data": [...]} format but the code
was checking if response.data is List directly. Now properly extracts
the data field before parsing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-10 17:40:04 -08:00
parent f8cfb5e597
commit eae6293b4a
1 changed files with 12 additions and 3 deletions

View File

@ -227,9 +227,18 @@ class AuthorizationService {
final response = await _apiClient.get(ApiEndpoints.myAuthorizations);
if (response.statusCode == 200) {
final data = response.data;
if (data is List) {
final authorizations = data
final responseData = response.data;
// API : {"success": true, "data": [...]}
// data
List<dynamic>? dataList;
if (responseData is Map<String, dynamic>) {
dataList = responseData['data'] as List<dynamic>?;
} else if (responseData is List) {
dataList = responseData;
}
if (dataList != null) {
final authorizations = dataList
.map((e) => AuthorizationResponse.fromJson(e as Map<String, dynamic>))
.toList();
debugPrint('授权列表获取成功: ${authorizations.length} 个授权');