feature/auth #2

Merged
m1000 merged 14 commits from feature/auth into main 2024-12-13 12:55:23 +00:00
6 changed files with 31 additions and 0 deletions
Showing only changes of commit 1dbd24f2e6 - Show all commits

View File

@ -0,0 +1,29 @@
"use client";
import { axiosInstance } from "@/app/lib/axios";
import { useRef } from "react";
export const FetchApi = () => {
const listRef = useRef<HTMLUListElement>(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 (
<div>
<button
className="text-white px-2 py-2 bg-green-500 rounded-md"
onClick={handleFetch}
>
Fetch API
</button>
<ul ref={listRef}></ul>
</div>
);
};

View File

@ -1,9 +1,11 @@
import Header from "./components/Header"; import Header from "./components/Header";
import { FetchApi } from "./components/FetchApi";
const HomePage = () => { const HomePage = () => {
return ( return (
<> <>
<Header /> <Header />
<FetchApi />
</> </>
); );
}; };