From 52fc2b5e074d3b29e880ab608a742131a947a350 Mon Sep 17 00:00:00 2001 From: M1000fr Date: Fri, 13 Dec 2024 18:16:43 +0100 Subject: [PATCH] Refactor: Update docker-compose.yml to remove unnecessary build and environment configurations --- docker-compose.yml | 5 ----- src/app/components/FetchApi.tsx | 18 ++++++++++++------ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5dc2772..ad0d926 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -3,8 +3,3 @@ services: image: toogether/webapp ports: - "80:3000" - build: - context: ./ - dockerfile: Dockerfile - environment: - - NEXT_PUBLIC_API_URL=http://api:3000 \ No newline at end of file diff --git a/src/app/components/FetchApi.tsx b/src/app/components/FetchApi.tsx index 006f5cd..733d777 100644 --- a/src/app/components/FetchApi.tsx +++ b/src/app/components/FetchApi.tsx @@ -1,18 +1,16 @@ "use client"; import { axiosInstance } from "@/app/lib/axios"; -import { useRef } from "react"; +import { useState } from "react"; export const FetchApi = () => { - const listRef = useRef(null); + const [date, setDate] = useState(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); + setDate(response.data.message); }; return ( @@ -23,7 +21,15 @@ export const FetchApi = () => { > Fetch API -
    +
    + {date ? ( +

    Server time: {date}

    + ) : ( +

    + Click the button to fetch the API +

    + )} +
    ); };