Posts

Showing posts from April, 2024

React Router and Authentication

 To use react router in react js first we have to import react router. 1 import {createBrowserRouter} from "react-router-dom". 2 import routerProvider which is a contextapi built by react which takes router. 3 Create a constant router which contains the routes which is in an object. 4 The route consists of two parts; path and element where path is the location of the element and element is the component to be route. Eg:   const router = createBrowserRouter ([     {       path : "/" ,       element : < Homepage /> ,     },     {       path : "/profilePage" ,       element : < ProfilePage /> ,     },     {       path : "/profiles" ,       element : < Profiles /> ,     },   ]); 5 Then we import Link to link the component route by using the path declared in constant router. Eg; < Link to = "/" ...

Git

 Commands/Steps 1. git init     (to initialize and is used once at the start of the project) 2. git remote origin (github link)     (used one time and set the link of github to "origin") 3. git add a.txt     (used to push a file here, a.txt) 4. git add .     (used to push all the files) 5.git commit -m "message"     (used to commit file to the repo , -m represent message and message should be in present continuous like "adding files") 6. git push origin     (used to push the files into the origin) 7. git commit -am "message"     (used to commit files similar to previous commit and merging both commits) 8. git branch      (shows the current branch the user is in) 9. git checkout -b "login"     (creates a new branch named "login" and switches the branch to "login") 10. git checkout master/main     (switches the branch to main or master) 11. git pull origin     (pulls the...

JWT(JSON Web Token)

Image
 JWT 1 It consists of three parts separated by (.);       header . payload . signature 2 Header consists of keys to be used in signature. It has algorithm and token type. 3 Payload consists of data of the token. Usually name, id and token created time. 4 Signature consists of both header and payload along with a secret key to identify if it is the right accessing the the token.

REST API

 1 REST API is used to communicate between client and server. 2 Restful is a web server for REST API to communicate. 3 The main blocks of REST API are;     the request that it send by the user to the server     the response that is received by the user from the server as per request. 4 While communicating with the server, the use; CRUD;     Create =>POST     Read=>GET     Update=>PUT     Delete=>DELETE 5 Request consists of;      Header : consists of API keys     Operator : consists of CRUD     Endpoint : consists of endpoint we want to access     Parameter : consists of the parameter of endpoint. 6 According to requests and commands API are generated as response.