uptownhr / nuxt-express-module

Add express routes to your nuxt app
MIT License
61 stars 4 forks source link

How to add default path prefix to router #8

Closed josteph closed 5 years ago

josteph commented 5 years ago

Hello, I am fairly new to express.

How do I add prefix to express router with this module? Normally it would be done like below:

const express = require('express')
const app = express()

app.post('/user/login', (req, res) => {
   //
})

module.exports = { 
   path: '/api',
   handler: app
}

or app.use('/api', router)

But in here, I can't use const app = express(), it will produce this error: error TypeError: require(...) is not a function

Thanks for any help.