From 1dbd24f2e62d6e1ab51b711c6dadba76aa6c3cbf Mon Sep 17 00:00:00 2001 From: M1000fr Date: Thu, 12 Dec 2024 18:58:43 +0100 Subject: [PATCH] refactor: change structure --- src/app/components/FetchApi.tsx | 29 +++++++++++++++++++++++++++++ src/{ => app}/lib/axios.ts | 0 src/{ => app}/lib/stringUtils.ts | 0 src/app/page.tsx | 2 ++ src/{ => app}/types/env.d.ts | 0 src/{ => app}/types/next-auth.d.ts | 0 6 files changed, 31 insertions(+) create mode 100644 src/app/components/FetchApi.tsx rename src/{ => app}/lib/axios.ts (100%) rename src/{ => app}/lib/stringUtils.ts (100%) rename src/{ => app}/types/env.d.ts (100%) rename src/{ => app}/types/next-auth.d.ts (100%) diff --git a/src/app/components/FetchApi.tsx b/src/app/components/FetchApi.tsx new file mode 100644 index 0000000..006f5cd --- /dev/null +++ b/src/app/components/FetchApi.tsx @@ -0,0 +1,29 @@ +"use client"; +import { axiosInstance } from "@/app/lib/axios"; +import { useRef } from "react"; + +export const FetchApi = () => { + const listRef = useRef(null); + + const handleFetch = async () => { + const response = await axiosInstance.get<{ + message: string; + }>("/ping"); + + const li = document.createElement("li"); + li.textContent = response.data.message; + listRef.current?.appendChild(li); + }; + + return ( +
+ +
    +
    + ); +}; diff --git a/src/lib/axios.ts b/src/app/lib/axios.ts similarity index 100% rename from src/lib/axios.ts rename to src/app/lib/axios.ts diff --git a/src/lib/stringUtils.ts b/src/app/lib/stringUtils.ts similarity index 100% rename from src/lib/stringUtils.ts rename to src/app/lib/stringUtils.ts diff --git a/src/app/page.tsx b/src/app/page.tsx index 99f6387..9c3151f 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,9 +1,11 @@ import Header from "./components/Header"; +import { FetchApi } from "./components/FetchApi"; const HomePage = () => { return ( <>
    + ); }; diff --git a/src/types/env.d.ts b/src/app/types/env.d.ts similarity index 100% rename from src/types/env.d.ts rename to src/app/types/env.d.ts diff --git a/src/types/next-auth.d.ts b/src/app/types/next-auth.d.ts similarity index 100% rename from src/types/next-auth.d.ts rename to src/app/types/next-auth.d.ts