You need to start working on a React project but API hasn't been implemented yet. Auth & API request is your main concern right now ?
Aim of this gist is to quickly setup a mocking API server with JWT support
I'm assuming Node.js & NPM are installed on your workstation
run npm install
in folder
run node index.js
in folder
- There's a public POST method '/login' which typically allows user to ... login
- There's a private GET method '/users/' that is meant to return whole database's user collection
- You can login with any account available in database's 'users' collection
I'm assuming you're using Postman. Request :
- POST
- In Body : choose
x-www-form-urlencoded
- field 'usermail' : any user's usermail available in
db.json
- field 'password' : user's password
As a result, you obtain a JWT token containing whole user record. keep it in clipboard.
I'm assuming you're using Postman. Request :
- GET
- In Header
- field 'Authorization' :
Bearer ${JWTtoken}
As a result, you get user list.