Hotfix to new note

This commit is contained in:
keannu125 2023-02-23 22:33:40 +08:00
parent 3f5fb0f79e
commit e8150d864f
2 changed files with 4 additions and 2 deletions

View file

@ -8,13 +8,14 @@ import axios from "axios";
export default function NoteMapper() { export default function NoteMapper() {
const navigate = useNavigate(); const navigate = useNavigate();
const [notes, setNotes] = useState([{ title: "", content: "" }]); const [notes, setNotes] = useState([]);
const [error, setError] = useState(false); const [error, setError] = useState(false);
const [errormessage, seterrormessage] = useState(""); const [errormessage, seterrormessage] = useState("");
useEffect(() => { useEffect(() => {
axios axios
.get("http://localhost:8000/notes/") .get("http://localhost:8000/notes/")
.then((res) => { .then((res) => {
console.log("Server Response", res.data);
setNotes(res.data); setNotes(res.data);
}) })
.catch((err) => { .catch((err) => {
@ -50,6 +51,7 @@ export default function NoteMapper() {
return ( return (
<> <>
{notes.map((note: { title: string; content: string }, i) => { {notes.map((note: { title: string; content: string }, i) => {
console.log(note);
return <Note key={i} title={note.title} content={note.content} />; return <Note key={i} title={note.title} content={note.content} />;
})} })}

View file

@ -44,7 +44,7 @@ export default function NewNote() {
variant="contained" variant="contained"
onClick={async () => { onClick={async () => {
axios.post("http://localhost:8000/notes/", { axios.post("http://localhost:8000/notes/", {
title: note.content, title: note.title,
content: note.content, content: note.content,
}); });
console.log("foo"); console.log("foo");