add tanstack/react-query
This commit is contained in:
+13
-14
@@ -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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user