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 directions request. When the controller aborts, the promise it returns rejects with a DOMException whose name is "AbortError".
const controller = new AbortController();
const directions = new mapkit.Directions();
try {
const response = await directions.route({
origin: "San Francisco",
destination: "Los Angeles",
signal: controller.signal,
});
} catch (error) {
if (error.name === "AbortError") {
// The request was canceled.
}
}
// Cancel the request at any time:
controller.abort();