request method

Future<StrapiResponse> request(
  1. String path, {
  2. Map<String, dynamic>? body,
  3. String? method,
  4. Map<String, String>? params,
  5. String? queryString,
  6. int? maxTimeOutInMillis,
})

an authentcated strapi request making towards the endpionts of your strapi server, in every request you make a authorization token is inserted automatically if the strapiToken is present otherwise the request will be plain unauthenticated request, host will be used a your strapi server path will be your endpoint, for example if you need to count restaurants collection

final response = request("/restaurants/count");
print(response.count);

body should be the json data you need to post or or (do not forget to change method too) method should be the required http request type for the endpoint, defaluts to 'GET' params will be custom key value pair arguments to pas in the url of the request

Implementation

Future<StrapiResponse> request(
  String path, {
  Map<String, dynamic>? body,
  String? method,
  Map<String, String>? params,
  String? queryString,
  int? maxTimeOutInMillis,
}) async {
  final response = await _request(
    path,
    body: body,
    method: method ?? "GET",
    params: params,
    queryString: queryString,
    maxTimeOutInMillis: maxTimeOutInMillis ?? Strapi.i.maxTimeOutInMillis,
  );
  return response;
}