DEV Community

Discussion on: JavaScript: Async/Await Wrapper

Collapse
 
dewaldels profile image
Dewald Els • Edited

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.