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

# route(request, callback)

Retrieves directions and estimated travel time based on the specified start and end points.

```
route(
    request: DirectionsRequest,
    callback: (
        error: Error | null,
        result: DirectionsResponse | null,
    ) => void,
): Promise<DirectionsResponse>;
```

## Parameters

`request`

A [`DirectionsRequest`](/documentation/MapKitJS/DirectionsRequest) object that specifies details for the directions you want to retrieve.

`callback`

A callback function that receives the directions, returned asynchronously.

## Return Value

A promise that resolves with a [`DirectionsResponse`](/documentation/MapKitJS/DirectionsResponse) on success.

## Discussion

Call the [`route(request, callback)`](/documentation/MapKitJS/Directions/route1) method to get directions.

MapKit JS returns directions asynchronously via a callback function. This callback function is invoked with two arguments, `error` on failure and `data` on success.

`error` contains an error code and a text description of the error. `data` is a [`DirectionsResponse`](/documentation/MapKitJS/DirectionsResponse) object with the following two properties:

- [`request`](/documentation/MapKitJS/DirectionsResponse/request) is the request object associated with this response.
- [`routes`](/documentation/MapKitJS/DirectionsResponse/routes) contains an array of up to three [`Route`](/documentation/MapKitJS/Route) objects returned by the server.

---

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)