<!--
{
  "availability" : [
    "MapKit JS: 5.0.0 - 6.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "MapKitJS",
  "identifier" : "/documentation/MapKitJS/Service/cancel",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "MapKit JS"
    ],
    "preciseIdentifier" : "instm/mapkit.Service/cancel"
  },
  "title" : "cancel(promise)"
}
-->

# cancel(promise)

Cancels a request using the provided request promise.

```
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.

## Return Value

`true` if the server cancels the pending search request.

## 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)`](/documentation/MapKitJS/Service/cancel) method:

```javascript
const search = new mapkit.Search();
const promise = search.search("coffee");

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

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)