post static method

Future<Response> post(
  1. String url, {
  2. Map<String, String>? headers,
  3. Object? body,
  4. Duration timeout = const Duration(seconds: 30),
})

POST 请求

Implementation

static Future<http.Response> post(
  String url, {
  Map<String, String>? headers,
  Object? body,
  Duration timeout = const Duration(seconds: 30),
}) async {
  _logRequest('POST', url, headers: headers, body: body);

  try {
    final response = await http
        .post(Uri.parse(url), headers: headers, body: body)
        .timeout(timeout);

    _logResponse('POST', url, response);
    return response;
  } catch (e) {
    _logError('POST', url, e);
    rethrow;
  }
}