infounik pintar
infounik pintar

Reputation: 3

How to users only can see their own data, node js rest api with mysql

Can somebody tell me about the general logic how to users only GET the data of their own only.

I'm doing making Rest-API with node.js+express+mysql. I already created CRUD operation with simple authentication. But I still vague about the logic, how the rest-api knows about the id of users that already login in app.

Please tell me the logic in GET but only the users already login can see their own data.

users can have multiple data. Thanks a lot

Upvotes: 0

Views: 739

Answers (1)

TRomesh
TRomesh

Reputation: 4481

You can save userID or any other unique property(any type of a key) to recognize users in your local storage(in the browser). When you make a request you can retrieve the userID or key and send it along with the REST call to the back end, So when the request reach the server it will contain the userID or Key that will allow you to query the database and retrieve the relevant data.

Upvotes: 1

Related Questions