signal
A signal object allowing you to cancel the request.
Declaration
signal?: AbortSignal;Discussion
Pass an AbortSignal from an AbortController to allow the controller to cancel a pending search or autocomplete request. When the controller aborts, the promise it returns rejects with a DOMException whose name is "AbortError".
const controller = new AbortController();
const search = new mapkit.Search();
try {
const data = await search.search("coffee", { signal: controller.signal });
// Handle results.
} catch (error) {
if (error.name === "AbortError") {
// The request was canceled.
}
}
// Cancel the request at any time:
controller.abort();