---
title: cancel(promise)
framework: mapkitjs
role: symbol
role_heading: Instance Method
path: mapkitjs/service/cancel
---

# cancel(promise)

Cancels a request using the provided request promise.

## Declaration

```data
cancel(promise: Promise<unknown>): boolean;
```

## Parameters

- `promise`: Pass the promise returned from the service method. Passing an invalid promise or the promise of a completed request has no effect.

## Mentioned in

Migrating from Version 5 to Version 6

## Return Value

Return Value true if the server cancels the pending search request.

## Discussion

Discussion Sometimes you need to cancel a request, either because a person initiates the cancellation or moves on to another activity. The preferred way to cancel a request is to use an AbortSignal. Pass the signal property of an AbortController to the service method’s options, and call abort() on the controller when you need to cancel the request. Alternatively, you can cancel a request by passing its returned promise to the cancel(promise) method: const search = new mapkit.Search(); const promise = search.search("coffee");

// Cancel the request: search.cancel(promise);
