request

Last updated:

0 purchases

request Image
request Images
Add to Cart

Description:

request

request #
A minimal abstraction of the 'http' package's 'get' and 'post'
methods that automatically throws an exception when any non-200
status code is returned.
Usage #
import 'package:request/request.dart' as http;
copied to clipboard
Like http, request exposes the [get] and [post] methods, which directly
wrap http's equivalent methods, but throw a [HttpStatusException] when any
status other than 200 is returned.
final response = await http.get(uri);
copied to clipboard
final reponse = await http.post(uri);
copied to clipboard
Additionally, request exposes the [request] method, which wraps [get] and
returns the response's body as a [String]. Like [get] and [post], an exception
will be thrown when any status other than 200 is returned.
final body = await http.request(uri);
copied to clipboard
Uri Extension Methods #
[get], [post], and [request] are also available as extension methods on
Dart's [Uri] object.
final url = Uri.parse('https://pub.dev/packages/request');
final body = await url.request();
copied to clipboard
HttpStatusException #
Returned [HttpStatusException]s contain the original [response], and has getters
for the requested [url], [statusCode] and [message].
[message] defaults to [response.reasonPhrase], and if null, falls back to the
standard status code phrases as defined by the W3C.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.