Skip to content

A wrapper of Dart http package.

License

Notifications You must be signed in to change notification settings

educup/request-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RequestAPI

A wrapper of Dart http package.

Getting started

import 'package:request_api/request_api.dart';

class ExampleApi {
  static void init() {
    // RequestAPI.init(authority, bearerToken);
    RequestAPI.init('example.com', 'Bearer Example');
  }

  static Future<Model> getModel(
    String arg, {
    http.Client client,
  }) async {
    var data = await Request.get('api/model/$arg', client: client);
    var parser = () => parseItem<Model>(
          data.body,
          Model.fromJson,
        );
    var result = await tryParse(parser);
    return result;
  }
}

IMPORTANT: outdated Readme.