From f73b802392de196643f0c0b55b905481b0e33322 Mon Sep 17 00:00:00 2001 From: thosakwe Date: Sun, 12 Feb 2017 14:58:18 -0500 Subject: [PATCH] 23 --- README.md | 2 +- lib/angel_client.dart | 2 +- lib/base_angel_client.dart | 8 ++------ lib/io.dart | 3 ++- pubspec.yaml | 2 +- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f4a2f22d..2a9624ee 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # angel_client -[![pub 1.0.0-dev+22](https://img.shields.io/badge/pub-1.0.0--dev+22-red.svg)](https://pub.dartlang.org/packages/angel_client) +[![pub 1.0.0-dev+23](https://img.shields.io/badge/pub-1.0.0--dev+23-red.svg)](https://pub.dartlang.org/packages/angel_client) ![build status](https://travis-ci.org/angel-dart/client.svg) Client library for the Angel framework. diff --git a/lib/angel_client.dart b/lib/angel_client.dart index 0915bdb8..86a808e1 100644 --- a/lib/angel_client.dart +++ b/lib/angel_client.dart @@ -90,7 +90,7 @@ abstract class Service { Angel get app; /// Retrieves all resources. - Future index([Map params]); + Future index([Map params]); /// Retrieves the desired resource. Future read(id, [Map params]); diff --git a/lib/base_angel_client.dart b/lib/base_angel_client.dart index 3372d35f..831177ea 100644 --- a/lib/base_angel_client.dart +++ b/lib/base_angel_client.dart @@ -229,7 +229,7 @@ class BaseAngelService extends Service { } @override - Future index([Map params]) async { + Future index([Map params]) async { final response = await app.sendUnstreamed( 'GET', '$basePath/${_buildQuery(params)}', _readHeaders); @@ -239,11 +239,7 @@ class BaseAngelService extends Service { } final json = JSON.decode(response.body); - - if (json is! List) { - throw failure(response); - } - + if (json is! List) return json; return json.map(deserialize).toList(); } catch (e, st) { throw failure(response, error: e, stack: st); diff --git a/lib/io.dart b/lib/io.dart index 9b666f4c..caec159e 100644 --- a/lib/io.dart +++ b/lib/io.dart @@ -47,8 +47,9 @@ class RestService extends BaseAngelService { } @override - Future index([Map params]) async { + Future index([Map params]) async { final items = await super.index(params); + if (items is! List) return items; return items.map(deserialize).toList(); } diff --git a/pubspec.yaml b/pubspec.yaml index 23f2c06e..52d5a01a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: angel_client -version: 1.0.0-dev+22 +version: 1.0.0-dev+23 description: Client library for the Angel framework. author: Tobe O homepage: https://github.com/angel-dart/angel_client