const routes = (app) => {
app.route('/contact')
.get((req, res, next) => {
// middleware
console.log(`Request from: ${req.originalUrl}`)
console.log(`Request type: ${req.method}`)
next();
}, (req, res, next) => {
res.send('GET request successful!!!!');
})
.post((req, res) =>
res.send('POST request successful!!!!'));
app.route('/contact/:contactId')
.put((req, res) =>
res.send('PUT request successful!!!!'))
.delete((req, res) =>
res.send('DELETE request successful!!!!'));
}
export default routes;
Produces this error when executing:
export default routes;
^^^^^^
SyntaxError: Unexpected token export
I'm actually trying to follow along in a training video so I'm a bit new to this. From my understanding he's trying to use ES6 and I know some commands, like import, aren't available in node ver 9 natively. Could this be one of them? Any alternatives?