I have a login system that works without an API. The username is "test" and the password is "1234".
I would like to create a system that handles 2 users. I created a file.json file with two users.
file.json
{
"login": [{
"id": 1,
"user": "toto",
"password": "1234"
},
{
"id": 2,
"user": "titi",
"password": "1234"
}
]
}
What files do I need to manage the connection with an API? Because I'm a beginner, I don't fully understand.
Which files should I modify/use in my project below, please?
https://stackblitz.com/edit/github-ey2nzj?file=src/app/views/identity/identity.component.ts
CodePudding user response:
Correct me if I'm wrong, you want a system that will handle multiple authenticated users? If so, Just create a service that will handle your API calls under /src/app/services folder and store your users details like token in localStorage
Probably you can store a simple structure like this
{
auth:[
{token:'1231212', name:'user 1'},
{token:'1231212', name:'user 2'}
]
}
CodePudding user response:
I have created something similar with this: https://www.npmjs.com/package/json-server
You can use the normal http methods like get, post, etc
