diff --git a/package-lock.json b/package-lock.json index f803556..9bec7d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,7 @@ "@types/node": "^16.18.12", "@types/react": "^18.0.28", "@types/react-dom": "^18.0.11", + "axios": "^1.3.3", "localforage": "^1.10.0", "match-sorter": "^6.3.1", "react": "^18.2.0", @@ -5262,6 +5263,29 @@ "node": ">=4" } }, + "node_modules/axios": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.3.3.tgz", + "integrity": "sha512-eYq77dYIFS77AQlhzEL937yUBSepBfPIe8FcgEDN35vMNZKMrs81pgnyrQpwfy4NF4b4XWX1Zgx7yX+25w8QJA==", + "dependencies": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/axios/node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/axobject-query": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.1.1.tgz", @@ -14353,6 +14377,11 @@ "node": ">= 0.10" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "node_modules/psl": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", diff --git a/package.json b/package.json index a99d56b..fee4f50 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "@types/node": "^16.18.12", "@types/react": "^18.0.28", "@types/react-dom": "^18.0.11", + "axios": "^1.3.3", "localforage": "^1.10.0", "match-sorter": "^6.3.1", "react": "^18.2.0", diff --git a/src/Components/Note/NoteMapper/NoteMapper.tsx b/src/Components/Note/NoteMapper/NoteMapper.tsx new file mode 100644 index 0000000..0217761 --- /dev/null +++ b/src/Components/Note/NoteMapper/NoteMapper.tsx @@ -0,0 +1,65 @@ +import * as React from "react"; +import styles from "../../../styles"; +import { useEffect, useState } from "react"; +import { useNavigate } from "react-router-dom"; +import Note from "../Note"; +import { Button } from "@mui/material"; + +export default function NoteMapper() { + const navigate = useNavigate(); + const [notes, setNotes] = useState([]); + const [error, setError] = useState(false); + const [errormessage, seterrormessage] = useState(""); + useEffect(() => { + fetch("localhost:8000/notes") + .then((res) => res.json()) + .then((data) => { + console.log(data); + setNotes(data); + }) + .catch((err) => { + setError(true); + console.log(err.message); + seterrormessage(err.message); + }); + }, []); + if (error) { + return ( +
404
+{errormessage}
+No notes exist yet
+Make one!
+ +New Note
Title:
+ { + setNote({ ...note, title: e.target.value }); + }} + maxLength={20} + /> +Content
- +