NCFRONT-17 change endpoints #3

Merged
frontdev merged 2 commits from NCFRONT-17 into main 2025-12-17 14:29:12 +08:00
2 changed files with 20 additions and 12 deletions
Showing only changes of commit 8541916e4c - Show all commits
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "no-copy-frontend", "name": "no-copy-frontend",
"version": "0.1.0", "version": "0.1.1",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev -p 2999", "dev": "next dev -p 2999",
+19 -11
View File
@@ -75,11 +75,15 @@ export async function authorization(
try { try {
const { email, password } = validatedFields.data; const { email, password } = validatedFields.data;
const response = await fetch(`${API_BASE_URL}/v1/api/auth/login`, { const response = await fetch(`${API_BASE_URL}/api/v1/data`, {
method: 'POST', method: 'POST',
body: JSON.stringify({ body: JSON.stringify({
email: email, version: 1,
password: password msg_id: 20001,
message_body: {
email: email,
password: password
}
}), }),
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@@ -88,7 +92,7 @@ export async function authorization(
}); });
if (response.ok) { if (response.ok) {
let parsed = await response.json(); let parsed = await response.json();
await createSession(parsed.token, email); await createSession(parsed.message_body.token, email);
} else { } else {
throw ('request-ended-with-an-error'); throw ('request-ended-with-an-error');
} }
@@ -175,14 +179,18 @@ export async function registration(
try { try {
const { full_name, email, password, phone } = validatedFields.data; const { full_name, email, password, phone } = validatedFields.data;
const response = await fetch(`${API_BASE_URL}/v1/api/auth/register`, { const response = await fetch(`${API_BASE_URL}/api/v1/data`, {
method: 'POST', method: 'POST',
body: JSON.stringify({ body: JSON.stringify({
fullName: full_name, version: 1,
email, msg_id: 20002,
phone: phone, message_body: {
password, fullName: full_name,
companyName: company, email,
phone: phone,
password,
companyName: company,
}
}), }),
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
@@ -198,7 +206,7 @@ export async function registration(
let parsed = await response.json(); let parsed = await response.json();
console.log('--parsed--'); console.log('--parsed--');
console.log(parsed); console.log(parsed);
await createSession(parsed.token, email); await createSession(parsed.message_body.token, email);
} else { } else {
throw (`${response.status}`); throw (`${response.status}`);
} }