This commit is contained in:
smanylov
2025-12-27 11:54:54 +07:00
parent ab6e385984
commit aaa95091d2
10 changed files with 134 additions and 187 deletions
+1 -26
View File
@@ -1,31 +1,6 @@
'use server'
import { getSessionData } from '@/app/actions/session';
import { localDevelopmentUrl, testUserData, API_BASE_URL } from '@/app/actions/definitions';
const FRUITS_URL = 'https://www.fruityvice.com/api/fruit/';
const ALL = 'all';
export async function fetchFruits() {
try {
const response = await fetch(FRUITS_URL + ALL, { 'method': 'GET' });
let parsed = await response.json();
return parsed;
} catch (error) {
console.error('Error:', error);
throw new Error('Failed to fetch fruits data.');
}
}
export async function fetchFruit(id: number) {
try {
const response = await fetch(FRUITS_URL + id, { 'method': 'GET' });
let parsed = await response.json();
return parsed;
} catch (error) {
console.error('Error:', error);
throw new Error('Failed to fetch fruits data.');
}
}
import { testUserData, API_BASE_URL } from '@/app/actions/definitions';
export async function getUserData() {
const userEmail = await getSessionData('email');