-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
38 lines (26 loc) · 854 Bytes
/
App.js
File metadata and controls
38 lines (26 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// src/App.jsx
import React from 'react';
const App = () => {
const { isLoading, data, error, refetch, executeMethod } = useScrew('user');
console.log(data)
const handleCreateUser = async () => {
try {
const newUser = { name: 'John Doe', email: 'john@example.com' };
const response = await executeMethod('create', newUser);
console.log('Utilisateur créé :', response);
} catch (err) {
console.error(err);
}
};
if (isLoading) return <p>Chargement...</p>;
if (error) return <p>Erreur: {error.message}</p>;
return (
<div>
<h1>Liste des Utilisateurs</h1>
{data && <pre>{JSON.stringify(data, null, 2)}</pre>}
<button onClick={refetch}>Rafraîchir</button>
<button onClick={handleCreateUser}>Créer un utilisateur</button>
</div>
);
};
export default App;