Skip to main content
The routes method is where you define how you fetch the generated view from the Delivery API If your view should be routable you must implement the routes method and call context methods to build routes.
Routes example

RoutesContext object

The RoutesContext object is passed into the routes method and gives you access to a set of methods which is described below.

Methods

handle

Handle allows you to specify a key from which you can fetch the view from the Delivery API. handle(handle)

Parameters

lookup

Lookup allows you to search source entities using a filter string and build dynamic handles or URLS based on data from other source entities. Note the lookup is an async function so you have to use async/await or then when you are using the lookup function. lookup(filter)
The lookup function is limited to a maximum number of items to return, based on the tenant plan. It can however be increased per tenant basis. Please reach out to Enterspeed if needed.The default limits are:
  • Free & Premium plans: 100 items
  • Enterprise plan: 500 items

Parameters

Required function calls

After the lookup function it’s required to call toPromise to excecute the query and return a promise.
Using the toPromise function excecutes the query and return a promise you must resolve.
look toPromise

Optional function calls

To filter the source entities even further you can call some of the following optional functions.
The limit function limits the number of source entities.

Parameters

look and limit
The order sequence of the source entities.

Parameters

lookup and orderBy
The sourceGroup function lets you specify the source group. By default the source group of the current source entity is used.

Parameters

If not defined, it uses the current source group.
lookup and sourceGroup

Examples

lookup using async/await
lookup using 'then'

url

url allows you to specify a url from which you can fetch the view from the delivery. url(url)

Parameters

Optional function calls
To the url function you can call some of the following optional functions.
The redirects function creates incomming redirects to a specific url.
Setting the redirects to an empty array clears any potential implicit redirects.

Parameters

routes with url and redirects

Examples

routes example with url and multiple handles
routes example with single url
routes can also be expressed as an arrow function expression to make it even more compact
You can then fetch the view using our Delivery API using either the url or one of the handles. You can also fetch multiple views in one request, although in this case it doesn’t make sense to fetch the same view three time, but just to demonstrate if you want to fetch multiple different views in one request.