I've trouble understanding the following javascript snippet. What I've learned so far is lambda functions have arguments (if any) & a body however the following method seems like it has an argument fn that lamda's into another set of arguments (req, res, next) & than it has a body that uses fn to call it.
This is super confusing for me. How exactly is this method working & how can it be written in simpler form?
const asyncMiddleware = fn =>
(req, res, next) => {
Promise.resolve(fn(req, res, next))
.catch(next);
};