add tanstack/react-query

This commit is contained in:
smanylov
2025-12-02 17:11:53 +07:00
parent d89cc35fca
commit 6d47fa7fbb
15 changed files with 209 additions and 94 deletions
+13 -14
View File
@@ -1,4 +1,5 @@
'use server'
import { getSessionData } from '@/app/lib/session';
const FRUITS_URL = 'https://www.fruityvice.com/api/fruit/';
const ALL = 'all'
@@ -25,26 +26,24 @@ export async function fetchFruit(id: number) {
}
}
export async function testConnect() {
export async function getUserData() {
const userEmail = await getSessionData('email');
const token = await getSessionData('token');
try {
const response = await fetch('http://localhost:8080/api/auth/register', {
method: 'POST',
body: JSON.stringify({
"fullName": "Vladislav Sergevich",
"email": "s2@e.ru",
"password": "1121231412"
}),
const response = await fetch(`http://localhost/api/user?email=${userEmail}`, {
method: 'GET',
headers: {
"Content-Type": "application/json",
"Accept": "application/json"
"Accept": "application/json",
"Authorization": `Bearer ${token}`,
}
});
let parsed = await response.json();
return parsed;
if (response.ok) {
return await response.json();
}
} catch (error) {
throw error;
console.error('error');
}
}