Unverified Commit 8c2cb464 authored by Lee Robinson's avatar Lee Robinson Committed by GitHub

Clarify data fetching documentation on calling API routes. (#19748)

We've received some feedback that the current note about calling API routes inside gSP/gSSP is confusing. This updates the wording to make it clear you can still use `fetch` in your application, and also to not say you "import" an API route. You import the _logic_ inside the route.
parent bb1bdbb1
......@@ -114,8 +114,8 @@ The `context` parameter is an object containing the following keys:
> This includes reading from the filesystem or a database.
> **Note**: You should not use [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) to
> call an API route in your application.
> Instead, directly import the API route and call its function yourself.
> call an API route in `getStaticProps`.
> Instead, directly import the logic used inside your API route.
> You may need to slightly refactor your code for this approach.
>
> Fetching from an external API is fine!
......@@ -661,8 +661,8 @@ The `context` parameter is an object containing the following keys:
> This includes reading from the filesystem or a database.
> **Note**: You should not use [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) to
> call an API route in your application.
> Instead, directly import the API route and call its function yourself.
> call an API route in `getServerSideProps`.
> Instead, directly import the logic used inside your API route.
> You may need to slightly refactor your code for this approach.
>
> Fetching from an external API is fine!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment