getPosts<T> method

Future<OrderedCollectionPage<T>> getPosts<T>(
  1. String nextUrl
)

Implementation

Future<OrderedCollectionPage<T>> getPosts<T>(String nextUrl) async {
  Uri nextUri = Uri.parse(nextUrl);

  if (nextUri.authority != Config.domainName) {
    nextUri = nextUri.asProxyUri();
  }

  http.Response pageResponse = await http.get(nextUri);
  String body = utf8.decode(pageResponse.bodyBytes);

  if (pageResponse.statusCode == 200) {
    OrderedCollectionPage<T> collection =
        OrderedCollectionPage<T>.fromJson(jsonDecode(body));
    return collection;
  } else {
    String message = "OutboxAPI returned non successful status code! \n\nThe body was: $body";
    Config.logger.e(message);
    throw FormatException(message);
  }
}