You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Step 3: Creating the Route with API Fetch Function
117
+
117
118
To call the TMDB API, we're going to create a server function that fetches data on the server. This approach keeps our API credentials secure by never exposing them to the client.
118
119
Let's create our route that fetches data from the TMDB API. Create a new file at `src/routes/fetch-movies.tsx`:
119
120
@@ -126,23 +127,22 @@ import { createServerFn } from '@tanstack/react-start'
-`createServerFn()` creates a server-only function that runs exclusively on the server, ensuring our `TMDB_AUTH_TOKEN` environment variable never gets exposed to the client. The server function makes an authenticated request to the TMDB API and returns the parsed JSON response.
164
164
- The route loader runs on the server when a user visits /fetch-movies, calling our server function before the page renders
0 commit comments