Hello I'm working on an app that obtains data from my own database, now I'm making a get request to obtain a JSON with more than one object and I'm trying to access to it. At least I want to print them in console.
Here is the main view:
api.findUsers();console.log(???);
And here the get request:
async findUsers(): Promise<User> { const { body } = await axios.get('/api/user', {headers: {'Authorization': 'Bearer eyJhdaR5cCI6IkpXVCJ9.eyJlbWdsamNvc25ldmFAaWNsb3VkLmNvbSIsImlhdCI6MTYyMTM3NjExNCwiZXhwIjoxNjIzOTY4MTE0fQ.3rGQuB4togouUYJM0xJ_ocTR5SsWadjYj7t_M'}} ); return UserFromJSON(body);}
What I get is the following data:
[{"id": 1,"name": "test","firstname": "test","lastname": "test","username": "test","email": "test","password": "test","phone": 1111},{"id": 2,"name": "test2","firstname": "test2","lastname": "test2","username": "test2","email": "test2@icloud.com","password": "test2","phone": 5064}
]
Also, How would it be to access the Json data from a get request that only returns one object?
Thank you in advance.