Skip to content

Commit

Permalink
update introductory sentence + another code snippet in Response
Browse files Browse the repository at this point in the history
  • Loading branch information
ArmandPhilippot committed Oct 16, 2024
1 parent ad4fc4b commit 72f1154
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/content/docs/en/guides/server-side-rendering.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,10 @@ See more details about [`Astro.cookies` and the `AstroCookie` type](/en/referenc

The example below sets a response status and status text for a product listing page when the product does not exist:

```astro title="src/pages/my-product.astro" {8-9}
```astro title="src/pages/product/[id].astro" {10,11}
---
export const prerender = false; // Not needed in 'server' mode
import { getProduct } from '../api';
const product = await getProduct(Astro.params.id);
Expand Down Expand Up @@ -262,9 +264,9 @@ Astro.response.headers.set('Cache-Control', 'public, max-age=3600');

#### Return a `Response` object

You can also return a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) object directly from any page using on-demand rendering.
You can also return a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) object directly from any page using on-demand rendering either manually or with [`Astro.redirect`](/en/reference/api-reference/#astroredirect).

The example below returns a 404 on a dynamic page after looking up an id in the database:
The example below looks up an ID in the database on a dynamic page and either it returns a 404 if the product does not exist, or it redirects the user to another page if the product is no longer available, or it displays the product:

```astro title="src/pages/[id].astro" {10-13, 18}
---
Expand Down

0 comments on commit 72f1154

Please sign in to comment.