bad request error on login route
This commit is contained in:
@@ -20,21 +20,25 @@ function LoginForm() {
|
||||
const displaySession = async () => {
|
||||
if (username === '' || password === '') return;
|
||||
|
||||
const response = await handleLogin(username, password);
|
||||
const json = await response?.json();
|
||||
|
||||
if (json) {
|
||||
const { session, userProfile } = json;
|
||||
let thisUser: userInfo = {
|
||||
firstName: userProfile.first_name,
|
||||
lastName: userProfile.last_name,
|
||||
id: userProfile.id,
|
||||
email: userProfile.email,
|
||||
password: userProfile.password,
|
||||
headers: session
|
||||
try {
|
||||
const response = await handleLogin(username, password);
|
||||
const json = await response?.json();
|
||||
|
||||
if (json) {
|
||||
const { session, userProfile } = json;
|
||||
let thisUser: userInfo = {
|
||||
firstName: userProfile.first_name,
|
||||
lastName: userProfile.last_name,
|
||||
id: userProfile.id,
|
||||
email: userProfile.email,
|
||||
password: userProfile.password,
|
||||
headers: session
|
||||
}
|
||||
|
||||
dispatch({ type: ActionType.USERLOGIN, payload: thisUser });
|
||||
}
|
||||
|
||||
dispatch({ type: ActionType.USERLOGIN, payload: thisUser });
|
||||
} catch(e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
import { userInfo } from '../types/main';
|
||||
const APISTRING = 'http://localhost:8088/api';
|
||||
|
||||
export const getAllUsers = async () => {
|
||||
let serverCall = await fetch('http://localhost:8088/users')
|
||||
let serverCall = await fetch(APISTRING + '/users')
|
||||
.then(res => res.json());
|
||||
|
||||
return serverCall;
|
||||
}
|
||||
|
||||
export const getOneUser = async (email: string) => {
|
||||
let serverCall = await fetch(`http://localhost:8088/users?email=${email}`)
|
||||
let serverCall = await fetch(`${APISTRING}/users?email=${email}`)
|
||||
.then(res => res.json());
|
||||
|
||||
return serverCall;
|
||||
}
|
||||
|
||||
export const registerNewUser = async (user: userInfo) => {
|
||||
let serverCall = await fetch('http://localhost:8088/register', {
|
||||
let serverCall = await fetch(APISTRING + '/register', {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
@@ -28,7 +29,7 @@ export const registerNewUser = async (user: userInfo) => {
|
||||
}
|
||||
|
||||
export const handleLogin = async (email: string, password: string) => {
|
||||
let serverCall = await fetch('http://localhost:8088/login', {
|
||||
let serverCall = await fetch(APISTRING + '/login', {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
@@ -47,7 +48,7 @@ export const unwrapLogin = async (email: string, password: string) => {
|
||||
}
|
||||
|
||||
export const getAllProducts = async () => {
|
||||
let serverCall = await fetch('http://localhost:8088/products', {
|
||||
let serverCall = await fetch(APISTRING + '/products', {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
@@ -58,7 +59,7 @@ export const getAllProducts = async () => {
|
||||
}
|
||||
|
||||
export const getProductDetails = async (productID: string) => {
|
||||
let serverCall = await fetch(`http://localhost:8088/products/${productID}`, {
|
||||
let serverCall = await fetch(`${APISTRING}/products/${productID}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
|
||||
Reference in New Issue
Block a user