mirror of
https://github.com/lemeow125/React-NotesApp.git
synced 2024-11-17 06:29:28 +08:00
Hotfix to new note
This commit is contained in:
parent
3f5fb0f79e
commit
e8150d864f
2 changed files with 4 additions and 2 deletions
|
@ -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} />;
|
||||
})}
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue