add registration and session logic
This commit is contained in:
@@ -1,69 +0,0 @@
|
||||
'use server'
|
||||
|
||||
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 testConnect() {
|
||||
try {
|
||||
const response = await fetch('http://localhost:8080/api/auth/register', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
"firstName": "Serg",
|
||||
"secondName": "Fedorovich",
|
||||
"lastName": "Tankan",
|
||||
"email": "gggpetst2test@e.ru",
|
||||
"password": "1121231412"
|
||||
}),
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Accept": "application/json"
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
let parsed = await response.json();
|
||||
|
||||
return parsed;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export async function authenticate(
|
||||
prevState: string | undefined,
|
||||
formData: FormData,
|
||||
) {
|
||||
try {
|
||||
console.log(formData);
|
||||
} catch (error) {
|
||||
if (error) {
|
||||
return 'Something went wrong.';
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export async function registration(
|
||||
prevState: string | undefined,
|
||||
formData: FormData,
|
||||
) {
|
||||
try {
|
||||
console.log(formData);
|
||||
} catch (error) {
|
||||
if (error) {
|
||||
return 'Something went wrong.';
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user