Skip to main content

iws_http 1.2.0 copy "iws_http: ^1.2.0" to clipboard
iws_http: ^1.2.0 copied to clipboard

Library to facilitate http requests with error handling for Rest API requests.

example/main.dart

// ignore_for_file: avoid_print
import 'package:iws_http/iws_http.dart';

void main() async {
  // Initialize IwsHttp singleton
  final iwsHttp = IwsHttp.setup(
    authority: 'jsonplaceholder.typicode.com',
    basePath: '/',
    defaultAuth: false, // Public API, does not require JWT Bearer token
  );

  try {
    // Perform a GET request to /posts/1
    final response = await iwsHttp.get(
      path: 'posts/1',
    );

    // response is already decoded from JSON to Map<String, dynamic>
    print('Post title: ${response['title']}');
    print('Post body: ${response['body']}');
  } on ApiException catch (e) {
    print('Request failed with HTTP status ${e.httpCode}: ${e.error}');
  }
}
0
likes
160
points
150
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Library to facilitate http requests with error handling for Rest API requests.

Homepage

License

MIT (license)

Dependencies

flutter, http, http_parser

More

Packages that depend on iws_http