diff --git a/src/Components/Note/NoteMapper/NoteMapper.tsx b/src/Components/Note/NoteMapper/NoteMapper.tsx index 0217761..faf2484 100644 --- a/src/Components/Note/NoteMapper/NoteMapper.tsx +++ b/src/Components/Note/NoteMapper/NoteMapper.tsx @@ -4,23 +4,22 @@ import { useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; import Note from "../Note"; import { Button } from "@mui/material"; +import axios from "axios"; export default function NoteMapper() { const navigate = useNavigate(); - const [notes, setNotes] = useState([]); + const [notes, setNotes] = useState([{ title: "", content: "" }]); const [error, setError] = useState(false); const [errormessage, seterrormessage] = useState(""); useEffect(() => { - fetch("localhost:8000/notes") - .then((res) => res.json()) - .then((data) => { - console.log(data); - setNotes(data); + axios + .get("http://localhost:8000/notes/") + .then((res) => { + setNotes(res.data); }) .catch((err) => { setError(true); - console.log(err.message); - seterrormessage(err.message); + seterrormessage(err); }); }, []); if (error) { @@ -31,26 +30,29 @@ export default function NoteMapper() { ); } - if (!notes) { -
No notes exist yet
-Make one!
- -No notes exist yet
+Make one!
+ +