flutter http headers code example
Example 1: flutter http.post headers
Future<dynamic> get(String url) async {
//Pass headers below
return http.post(url, headers: {"Authorization": "Some token"}).then(
(http.Response response) {
final int statusCode = response.statusCode;
LogUtils.d("====response ${response.body.toString()}");
if (statusCode < 200 || statusCode >= 400 || json == null) {
throw new ApiException(jsonDecode(response.body)["message"]);
}
return _decoder.convert(response.body);
});
}
Example 2: https requests flutter
dependencies:
http: ^0.12.2