From e8150d864fb339003d6e208339bea6c5349e4c34 Mon Sep 17 00:00:00 2001 From: keannu125 Date: Thu, 23 Feb 2023 22:33:40 +0800 Subject: [PATCH] Hotfix to new note --- src/Components/Note/NoteMapper/NoteMapper.tsx | 4 +++- src/Routes/NewNote/NewNote.tsx | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Components/Note/NoteMapper/NoteMapper.tsx b/src/Components/Note/NoteMapper/NoteMapper.tsx index faf2484..5a40a33 100644 --- a/src/Components/Note/NoteMapper/NoteMapper.tsx +++ b/src/Components/Note/NoteMapper/NoteMapper.tsx @@ -8,13 +8,14 @@ import axios from "axios"; export default function NoteMapper() { const navigate = useNavigate(); - const [notes, setNotes] = useState([{ title: "", content: "" }]); + const [notes, setNotes] = useState([]); const [error, setError] = useState(false); const [errormessage, seterrormessage] = useState(""); useEffect(() => { axios .get("http://localhost:8000/notes/") .then((res) => { + console.log("Server Response", res.data); setNotes(res.data); }) .catch((err) => { @@ -50,6 +51,7 @@ export default function NoteMapper() { return ( <> {notes.map((note: { title: string; content: string }, i) => { + console.log(note); return ; })} diff --git a/src/Routes/NewNote/NewNote.tsx b/src/Routes/NewNote/NewNote.tsx index 45e85fd..fff89df 100644 --- a/src/Routes/NewNote/NewNote.tsx +++ b/src/Routes/NewNote/NewNote.tsx @@ -44,7 +44,7 @@ export default function NewNote() { variant="contained" onClick={async () => { axios.post("http://localhost:8000/notes/", { - title: note.content, + title: note.title, content: note.content, }); console.log("foo");