delete method

Future<AsklessResponse> delete({
  1. required String route,
  2. Map<String, dynamic>? params,
  3. bool neverTimeout = false,
  4. bool persevere = false,
})

Performs a request attempt for a delete route added on the server side

route The path of the route.

params Additional data, indicate here which data will be removed.

neverTimeout Default: false (optional). If true: the request attempt will live as long as possible.

If false: if the request doesn't receive a response within the time limit, it will be canceled. The field requestTimeoutInMs defined on the server side will be the time limit.

persevere Default: false (optional). If persevere is true and this route was created in the server with addRouteFor.authenticatedUsers (requires authentication) but clearAuthentication() is called, then this route will wait for the authentication to come back. In case of false the route will be canceled right after clearAuthentication() is called (only if this route requires authentication). This is no-op in case this route doesn't require authentication (addRoute.forAllUsers).

Example

    AsklessClient.instance
       .delete(
           route: 'product',
           params: {
             'id': 1
           },
       ).then((res) => print(res.success ? 'Success' : res.error!.code));

Implementation

Future<AsklessResponse> delete({required String route, Map<String, dynamic>? params, bool neverTimeout = false, bool persevere = false}) async {
  await getIt.get<ConnectionService>().waitForConnectionOrTimeout(timeout: neverTimeout ? null : Duration(milliseconds: getIt.get<ConnectionService>().connectionConfiguration.requestTimeoutInMs));
  return getIt.get<RequestsService>().runOperationInServer(data: DeleteCli(route: route, params: params), neverTimeout: neverTimeout, isPersevere: () => persevere,);
}