Merge pull request 'NCFRONT-17 change endpoints' (#3) from NCFRONT-17 into main
Reviewed-on: #3
This commit was merged in pull request #3.
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "no-copy-frontend",
|
"name": "no-copy-frontend",
|
||||||
"version": "0.3.0",
|
"version": "0.4.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev -p 2999",
|
"dev": "next dev -p 2999",
|
||||||
|
|||||||
+12
-4
@@ -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({
|
||||||
|
version: 1,
|
||||||
|
msg_id: 20001,
|
||||||
|
message_body: {
|
||||||
email: email,
|
email: email,
|
||||||
password: password
|
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({
|
||||||
|
version: 1,
|
||||||
|
msg_id: 20002,
|
||||||
|
message_body: {
|
||||||
fullName: full_name,
|
fullName: full_name,
|
||||||
email,
|
email,
|
||||||
phone: phone,
|
phone: phone,
|
||||||
password,
|
password,
|
||||||
companyName: company,
|
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}`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user