Polished api and moved from axios to fetch

This commit is contained in:
keannu125 2023-02-25 21:27:26 +08:00
parent d96c26bc1a
commit 044f45e038
2 changed files with 7 additions and 3 deletions

View file

@ -1,7 +1,9 @@
import axios from "axios";
import { get } from "http";
export function GetNotes() { export function GetNotes() {
return fetch("http://localhost:8000/api/v1/notes/").then((res) => { return fetch("http://localhost:8000/api/v1/notes/").then((res) => {
const result = res.json(); console.log(res);
console.log(); return res.json();
return result;
}); });
} }

View file

@ -2,6 +2,7 @@ import * as React from "react";
import styles from "../../styles"; import styles from "../../styles";
import { Button } from "@mui/material"; import { Button } from "@mui/material";
import axios from "axios"; import axios from "axios";
import { useQueryClient } from "react-query";
export interface props { export interface props {
title: string; title: string;
@ -10,6 +11,7 @@ export interface props {
date_created: string; date_created: string;
} }
export default function Note(props: props) { export default function Note(props: props) {
const queryClient = useQueryClient();
return ( return (
<div style={styles.flex_column}> <div style={styles.flex_column}>
<div style={styles.note}> <div style={styles.note}>