Skip to content

Commit

Permalink
Add Steps component to call-endpoint.mdx (#8123)
Browse files Browse the repository at this point in the history
Co-authored-by: Sarah Rainsberger <[email protected]>
Co-authored-by: HiDeoo <[email protected]>
Co-authored-by: Reuben Tier <[email protected]>
  • Loading branch information
4 people authored May 2, 2024
1 parent 95f4e77 commit a67b103
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/content/docs/en/recipes/call-endpoints.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ description: Learn how to call endpoints from the server in Astro.
i18nReady: true
type: recipe
---
import { Steps } from '@astrojs/starlight/components';

Endpoints can be used to serve many kinds of data. This recipe calls a server endpoint from a page's component script to display a greeting, without requiring an additional fetch request.

Expand All @@ -13,6 +14,7 @@ Endpoints can be used to serve many kinds of data. This recipe calls a server en

## Recipe

<Steps>
1. Create an endpoint in a new file `src/pages/api/hello.ts` that returns some data:

```ts title="src/pages/api/hello.ts"
Expand All @@ -39,3 +41,4 @@ Endpoints can be used to serve many kinds of data. This recipe calls a server en
<h1>{data.greeting} world!</h1>
```
</Steps>

0 comments on commit a67b103

Please sign in to comment.