2025-11-25 17:13:16 +07:00
|
|
|
'use server'
|
|
|
|
|
|
2025-11-26 14:01:35 +07:00
|
|
|
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.');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-25 17:13:16 +07:00
|
|
|
export async function testConnect() {
|
|
|
|
|
try {
|
|
|
|
|
const response = await fetch('http://localhost:8080/api/auth/register', {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
body: JSON.stringify({
|
2025-11-27 21:33:53 +07:00
|
|
|
"fullName": "Vladislav Sergevich",
|
|
|
|
|
"email": "s2@e.ru",
|
2025-11-25 17:13:16 +07:00
|
|
|
"password": "1121231412"
|
|
|
|
|
}),
|
|
|
|
|
headers: {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
"Accept": "application/json"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
let parsed = await response.json();
|
|
|
|
|
|
|
|
|
|
return parsed;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
}
|