I'm a bit confused about this design. What is the proper way to use async/await? Here's a basic situation I'm dealing with:
I'm a client app using a REST API. I have a function like this:
//Class method to get user list.
async getUsers(url) {
let options = {
method: 'GET',
uri: url,
json: true,
headers: {
Authorization: this.authString
}
}
//Using request-promise module.
let users = await request(options)
return users
}
This method gets a list of users, then because the method is async, it returns the list in a promise. So basically, I'm getting the resolved value from the promise using 'await', but then it gets wrapped in another promise when I call getUsers(). I want to be able to return the user list and not a promise, but if I remove async keyword, I can't call await. What is the best approach for this kind of problem?