request method

Future<Response> request(
  1. dynamic path,
  2. RequestOption options
)

Implementation

Future<Response> request(path, RequestOption options) async {
  final aud = options.audience ?? audience;
  if (aud != null) {
    options.headers!['X-JWT-AUD'] = aud;
  }

  try {
    final token = await jwt();
    return api.request(
      path,
      data: options.body,
      options: Options(
        headers: {
          'Authorization': 'Bearer $token',
          ...options.headers ?? {},
        },
        contentType: options.contentType,
        method: options.method,
      ),
    );
  } on DioError catch (e) {
    debugPrint(e.toString());
    debugPrintStack();
    if (e.response!.statusCode == 404) {
      debugPrint(e.response!.statusCode.toString());
    } else {
      debugPrint(e.message);
      debugPrint(e.requestOptions.toString());
    }
    rethrow;
  }
}