use variable for api base url

This commit is contained in:
agatha 2024-04-09 17:50:06 -04:00
parent 82bd76618c
commit dc67c7eb10

View File

@ -3,11 +3,13 @@ import {useEffect, useState} from "react";
import axios from "axios"; import axios from "axios";
import PostList from "./components/Post/PostList"; import PostList from "./components/Post/PostList";
const apiUrl = "http://localhost:8000";
function App() { function App() {
const [postList, setPostsList] = useState([]); const [postList, setPostsList] = useState([]);
const fetchPosts = async () => { const fetchPosts = async () => {
await axios.get("http://localhost:8000/catalog") await axios.get(apiUrl + "/catalog")
.then((response) => { setPostsList(response.data)}) .then((response) => { setPostsList(response.data)})
} }
@ -38,4 +40,4 @@ function App() {
); );
} }
export default App; export default App;