DEV Community

Discussion on: JavaScript: Async/Await Wrapper

dewaldels profile image
Dewald Els Author • Edited on

I initially used a closure and thought of using the rest operator there, but I didn't like the syntax. Although, it does afford the ability to create functions to use later.

const fetchUsers = asyncWrapper(fetchUsersRequest);

// some other code
const [ users, error ] = await fetchUsers();
Enter fullscreen mode Exit fullscreen mode

I didn't see a need for this right now and decided to simplify it.