postData method

Future<Response?> postData(
  1. String endpoint,
  2. dynamic data, {
  3. Map<String, dynamic>? headers,
})

Implementation

Future<Response?> postData(String endpoint, dynamic data,
    {Map<String, dynamic>? headers}) async {
  try {
    _dio.options.headers['content-Type'] = 'application/json';
    _dio.options.headers['authorization'] = _bearerToken;
    final response = await _dio.post(
      Uri.encodeFull(endpoint),
      data: data,
      options: Options(headers: headers),
    );
    return response;
  } on DioError catch (e) {
    throw handleException(e);
  } catch (e) {
    print("ERROR postData $e");
    throw Exception(e);
  }
}