Fetch, Authentication, Databases
Fetch, Authentication, Databases
1
Fetch, Authentication and
Databases
The fetch API
Until now, we’ve sent requests
in 2 ways
Postman Browser URL bar
There’s a third way
Lets say I ask you create an HTML page where
1. You can see the names of 10 people
2. You need to make sure you get these data from an API call
HTTP Server
HTML code you need
to write
GET
https://fakerapi.it/api/v1/persons
There’s a third way
Lets say I ask you create an HTML page where
1. You can see the names of 10 people
2. You need to make sure you get these data from an API call
https://gist.github.com/hkirat/ea4d132f70f69d1d47baac9eb3cc1313
Authentication
Project for today -
Let people sign up to your website
Only allow signed in users to see people (create
a dummy people list)
Before that, lets see
authentication
Authentication
1. Hashing
2. Encryption
3. Json web tokens
4. Local storage
Authentication
1. Hashing
2. Encryption
3. Json web tokens
[email protected]
4. Local storage
123456
asd@#da23mSAd13
fi
Authentication
1. Hashing
2. Encryption
3. Json web tokens
[email protected]
4. Local storage
1234561
ddda123aassda131$
fi
Authentication
1. Hashing
2. Encryption
3. Json web tokens
[email protected]
4. Local storage
1234561
ddda123aassda131$
Authentication
1. Hashing
2. Encryption
3. Json web tokens
[email protected]
4. Local storage
1234561
ddda123aassda131$
Authentication
1. Hashing
2. Encryption
3. Json web tokens
[email protected]
4. Local storage
1234561
Signature
fi
Authentication
1. Hashing
2. Encryption
3. Json web tokens
4. Local storage
GET /users
POST /signin
Headers -
Body - {
Authorization header
username: string
password: string
}
Returns an array of all users if user is signed in (token is correct)
Returns 403 status code if not
Returns a json web token with username encrypted
https://gist.github.com/hkirat/1618d30e03dc2c276b1cd4b351028d14
Authentication Recap
How to start?
1. Create a MongoDB free instance by going to https://mongodb.com/
2. Get your mongoldb connection URL
3. Download MongoDB Compass and try to explore the DB
Databases