2023-12-04 23:17:46 +01:00
|
|
|
"use client";
|
|
|
|
|
|
|
|
import styles from "../page.module.css";
|
|
|
|
|
|
|
|
export const CallAPIButton = () => {
|
|
|
|
const fetchUserData = async () => {
|
2024-05-02 21:19:20 +02:00
|
|
|
const userInfoResponse = await fetch("http://localhost:3000/api/user");
|
2023-12-04 23:17:46 +01:00
|
|
|
|
|
|
|
alert(JSON.stringify(await userInfoResponse.json()));
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div onClick={fetchUserData} className={styles.sessionButton}>
|
|
|
|
Call API
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|