diff --git a/src/App.js b/src/App.js index 9a1e922..677a251 100644 --- a/src/App.js +++ b/src/App.js @@ -4,9 +4,11 @@ import Filters from "./components/Filters"; import Gallery from "./components/Gallery"; import Favorites from "./components/Favorites"; import BreedInfoPage from "./components/BreedInfoPage"; + import "./App.css"; import { debounce } from "lodash"; -const apikey ="live_8bnMZatSzkOR7eyT6o0iwDmXQuTxPI3deVWy0KY2ABxDkTMJdTYZ13S9lVFmrZRO" +import { apikey } from "./env"; + const App = () => { const [cats, setCats] = useState([]); const [loading, setLoading] = useState(true); diff --git a/src/components/BreedInfoPage.js b/src/components/BreedInfoPage.js index 2f3fef4..70a163d 100644 --- a/src/components/BreedInfoPage.js +++ b/src/components/BreedInfoPage.js @@ -1,8 +1,8 @@ import React, { useEffect, useState } from "react"; import { useParams, useNavigate } from "react-router-dom"; -const API_URL = "https://api.thecatapi.com/v1"; -const API_KEY = "live_8bnMZatSzkOR7eyT6o0iwDmXQuTxPI3deVWy0KY2ABxDkTMJdTYZ13S9lVFmrZRO"; +import { API_URL, apikey } from "../env"; +//const API_URL = "https://api.thecatapi.com/v1"; const BreedInfoPage = () => { const { id } = useParams(); @@ -19,7 +19,7 @@ const BreedInfoPage = () => { const breedResponse = await fetch(`${API_URL}/breeds/${id}`, { - headers: { "x-api-key": API_KEY }, + headers: { "x-api-key": apikey }, }); if (!breedResponse.ok) throw new Error("Failed to fetch breed information."); @@ -28,7 +28,7 @@ const BreedInfoPage = () => { const imageResponse = await fetch(`${API_URL}/images/search?breed_ids=${id}&limit=1`, { - headers: { "x-api-key": API_KEY }, + headers: { "x-api-key": apikey }, }); if (!imageResponse.ok) throw new Error("Failed to fetch breed image."); diff --git a/src/components/Favorites.js b/src/components/Favorites.js index 076ea47..1a58004 100644 --- a/src/components/Favorites.js +++ b/src/components/Favorites.js @@ -6,8 +6,8 @@ const Favorites = ({ favorites, onRemoveFavorite }) => {