diff --git a/src/App.tsx b/src/App.tsx
index 7945b6d..87db0d8 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -3,7 +3,9 @@ import HomePage from "./pages/Home";
function App() {
return (
-
+
+
+
);
}
diff --git a/src/mocks/handlers.ts b/src/mocks/handlers.ts
index 84a44a0..fac034f 100644
--- a/src/mocks/handlers.ts
+++ b/src/mocks/handlers.ts
@@ -2,7 +2,7 @@ import { http, HttpResponse } from "msw";
/* handlers: what ever request you want to mock you need an handler. interception */
export const handlers = [
- http.get("/resource", ({ request }) => {
+ http.get("/api/users", ({ request }) => {
return HttpResponse.json([
{ id: 1, name: "John Doe", email: "johndoe@gmail.com" },
{ id: 2, name: "Smith Williams", email: "smithwilliams@gmail.com" },
diff --git a/src/pages/Home/index.tsx b/src/pages/Home/index.tsx
index a5f0ef1..0637e14 100644
--- a/src/pages/Home/index.tsx
+++ b/src/pages/Home/index.tsx
@@ -1,7 +1,25 @@
import { motion } from "framer-motion";
+import { useEffect, useState } from "react";
import { Link } from "react-router";
+interface User {
+ id: number;
+ name: string;
+ email: string;
+}
+
const HomePage = () => {
+ const [users, setUsers] = useState([]);
+
+ useEffect(() => {
+ fetch("/api/users")
+ .then((response) => response.json())
+ .then((data) => setUsers(data))
+ .catch((error) => {
+ console.error(error);
+ });
+ }, []);
+
return (
{
>
Learn more
+
+
Mock Service Worker Example:
+
+ {users.map((user) => (
+ -
+ {user.name} | {user.email}
+
+ ))}
+
+
);
};