diff --git a/src/Components/Api/Api.tsx b/src/Components/Api/Api.tsx new file mode 100644 index 0000000..947730c --- /dev/null +++ b/src/Components/Api/Api.tsx @@ -0,0 +1,7 @@ +export function GetNotes() { + return fetch("http://localhost:8000/api/v1/notes/").then((res) => { + const result = res.json(); + console.log(); + return result; + }); +} diff --git a/src/Components/Notes/Notes.tsx b/src/Components/Notes/Notes.tsx index d877107..3ef5c35 100644 --- a/src/Components/Notes/Notes.tsx +++ b/src/Components/Notes/Notes.tsx @@ -6,20 +6,11 @@ import Note from "../Note/Note"; import { Button } from "@mui/material"; import axios from "axios"; import { useQuery } from "react-query"; +import { GetNotes } from "../Api/Api"; export default function Notes() { const navigate = useNavigate(); - const { - data: notes, - isLoading, - error, - } = useQuery("notes", () => { - return fetch("http://localhost:8000/api/v1/notes/").then((res) => { - const result = res.json(); - console.log(); - return result; - }); - }); + const { data: notes, isLoading, error } = useQuery("notes", GetNotes); if (error) { return (