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() {
|
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} />;
|
||||||
})}
|
})}
|
||||||
|
|
||||||
|
|
|
@ -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");
|
||||||
|
|
Loading…
Reference in a new issue