'Trying to use two middle ware passing them as array

app.use([logger,authorize])

Error: TypeError: Router.use() requires a middleware function but got a Object



Solution 1:[1]

You usually don't pass them as an array. You pass them as a comma seperated list as denoted by https://expressjs.com/en/4x/api.html#app.METHOD.

This would then be

app.use(logger,authorize)

However if you would like to call them as an array, take a look at function.apply

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 TheDome