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 PostList from "./components/Post/PostList";
const apiUrl = "http://localhost:8000";
function App() {
const [postList, setPostsList] = useState([]);
const fetchPosts = async () => {
await axios.get("http://localhost:8000/catalog")
await axios.get(apiUrl + "/catalog")
.then((response) => { setPostsList(response.data)})
}