Skip to content

Commit

Permalink
Adapter API reference: signature change in a function (#5510)
Browse files Browse the repository at this point in the history
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
  • Loading branch information
lilnasy and sarah11918 authored Dec 5, 2023
1 parent 9d88a55 commit b2874b8
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/content/docs/en/reference/adapter-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -193,20 +193,18 @@ export function start(manifest) {

The following methods are provided:

##### `app.render(request, routeData, locals)`
##### `app.render(request, { routeData, locals })`

This method calls the Astro page that matches the request, renders it, and returns a Promise to a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) object. This also works for API routes that do not render pages.

```js
const response = await app.render(request);
```

The method accepts a mandatory `request` argument, and two other optional arguments: [`routeData`](/en/reference/integrations-reference/#routedata-type-reference) and [`locals`](/en/reference/api-reference/#astrolocals).
The method accepts a mandatory `request` argument, and an optional argument for [`routeData`](/en/reference/integrations-reference/#routedata-type-reference) and [`locals`](/en/reference/api-reference/#astrolocals).

Provide a value for `routeData` if you already know the route to render. Doing so will bypass the internal call to [`app.match`](#appmatchrequest) to determine the route to render.

When used, `locals` must be the third argument passed. You can pass `undefined` for `routeData` if you are not targeting a specific route.

The example below reads a header named `x-private-header`, attempts to parse it as an object and pass it to `locals`, which can then be passed to any [middleware function](/en/guides/middleware/).

```js
Expand All @@ -217,7 +215,7 @@ try {
locals = JSON.parse(privateHeader);
}
} finally {
const response = await app.render(request, undefined, locals);
const response = await app.render(request, { locals });
}
```

Expand Down

0 comments on commit b2874b8

Please sign in to comment.