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() {
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 <Note key={i} title={note.title} content={note.content} />;
})}

View file

@ -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");