I'm looking to inspect the JSON data being sent and received by the server, but I'm struggling to understand how promises work in this scenario.
When I use console.log()
on the function body, I see Promise { pending }
. Unfortunately, I can't log 'users' outside of the promise due to it being out of scope.
Is there a way for me to access the data inside the code block provided?
function getAll(req, res, next) {
userService.getAll().then(users => res.json(users)).catch(err =>
next(err));
}
The expected output should be some JSON data displayed in the console.