- Overall process involves: making a use effect, to call your backend
(i.e., localhost:8080/api/login)
i. Front-end you send the user object to the back end
ii. Back-end receives that object and checks the database for the "sub_id"
a. matching sub_id -> return user that matches return to front-end
b. no matching -> insert user to database, then return to front-end
- Specific Tasks
[ ] 2.1 Start a new branch (connect front & back-end with login)
[ ] 2.2 Create "profile.js" file and to place this connection into file
[ ] 2.2.1 In back-end make a route called app.get('/api/login')
[ ] 2.2.2 Front-end you send the user object to the back end
[ ] 2.2.3 Back-end receives object & checks the database for the "sub_id"
a. matching sub_id -> return user that matches return to front-end
b. no matching -> insert user to database, then return to front-end
Use node-postgress query and to have function returns as promise)
Ensure` function accepts sub=_id & returns a promise that resolves)
- Example Code
user.sub_id === "google:oath-sj232ah18sh19sn3"
SELECT * FROM USERS WHERE sub_id = "google:oath-sj232ah18sh19sn3"
this is going to return NO MATCH
{
id: 1
email: aladf.com
first_name: John
last_name: nathan
sub_id: = "google:oath-sj232ah18sh19sn3"
}
Alvin's Notes (from Saturday's meeting) - Manpreet
1. AUTHO LOGIN
2. CONNECT FRONT & BACK END (with Login)
- Overall process involves: making a use effect, to call your backend
- Specific Tasks
- Example Code