From f767571bbbe59f7ec70b3962f70a7b543ffa52db Mon Sep 17 00:00:00 2001 From: Stephanie <126029841+HarrisSte@users.noreply.github.com> Date: Sat, 9 Sep 2023 12:04:33 -0400 Subject: [PATCH 1/2] ADD: .env & key info --- client/src/App.jsx | 2 ++ client/src/components/SelectedGenreGames.jsx | 6 +++++- client/src/main.jsx | 2 -- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/client/src/App.jsx b/client/src/App.jsx index 15e2cb9..c2cac7e 100644 --- a/client/src/App.jsx +++ b/client/src/App.jsx @@ -12,6 +12,8 @@ import { useCookies } from 'react-cookie'; import Header from './components/Header/NavLinks'; import Footer from './components/Footer/Footer'; + + function App() { const [cookies] = useCookies(['auth_token']); diff --git a/client/src/components/SelectedGenreGames.jsx b/client/src/components/SelectedGenreGames.jsx index ee24deb..4bc5720 100644 --- a/client/src/components/SelectedGenreGames.jsx +++ b/client/src/components/SelectedGenreGames.jsx @@ -1,9 +1,13 @@ import { useEffect, useState } from "react"; + + + const SelectedGenreGames = ({ genreId }) => { + const apiKey = import.meta.env.VITE_API_KEY; const [genreGames, setGenreGames] = useState([]); useEffect(() => { fetch( - `https://api.rawg.io/api/games?key=bf22dc51e531456db8bc42a19dac9897&genres=${genreId}` + `https://api.rawg.io/api/games/key=${apiKey}=${genreId}` ) .then((res) => res.json()) .then((data) => { diff --git a/client/src/main.jsx b/client/src/main.jsx index 1aa909e..ed7d090 100644 --- a/client/src/main.jsx +++ b/client/src/main.jsx @@ -20,7 +20,6 @@ import Login from './pages/Login/Login'; import Register from './pages/Register/Register'; import SingleGame from './pages/SingleGame'; import Results from './pages/Results/ResultsPage'; -// import SelectedGenreGames from './components/SelectedGenreGames'; import ProtectedRoute from './components/ProtectedRoute'; @@ -33,7 +32,6 @@ const router = createBrowserRouter( } /> } /> } /> - {/* } /> */} Date: Sat, 9 Sep 2023 12:32:51 -0400 Subject: [PATCH 2/2] UPDATE: main branch with current debugging process --- client/src/components/SelectedGenreGames.jsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/client/src/components/SelectedGenreGames.jsx b/client/src/components/SelectedGenreGames.jsx index 4bc5720..cda58c8 100644 --- a/client/src/components/SelectedGenreGames.jsx +++ b/client/src/components/SelectedGenreGames.jsx @@ -1,13 +1,14 @@ import { useEffect, useState } from "react"; +// import.meta.env.VITE_API_KEY; - + // console.log(import.meta.env.VITE_API_KEY); const SelectedGenreGames = ({ genreId }) => { - const apiKey = import.meta.env.VITE_API_KEY; + // const apiKey = import.meta.env.VITE_API_KEY; const [genreGames, setGenreGames] = useState([]); useEffect(() => { fetch( - `https://api.rawg.io/api/games/key=${apiKey}=${genreId}` + `https://api.rawg.io/api/games?key=bf22dc51e531456db8bc42a19dac9897&genres=${genreId}` ) .then((res) => res.json()) .then((data) => {