I'm new to Node and created an app that has some async/await syntax in it like so:
const express = require('express');
const app = express();
const someLibrary = require('someLibrary');
function asyncWrap(fn) {
return (req, res, next) => {
fn(req, res, next).catch(next);
};
};
app.post('/getBlock', asyncWrap(async (req,res,next) => {
let block = await someLibrary.getBlock(req.body.id);
[some more code]
}));
app.listen(process.env.PORT || 8000);
It works fine on my machine but when I deploy to Heroku I get an error because the syntax is not supported:
2017-03-23T10:11:13.953797+00:00 app[web.1]: app.post('/getBlock', asyncWrap(async (req,res,next) => {
2017-03-23T10:11:13.953799+00:00 app[web.1]: SyntaxError: Unexpected token (
What is the easiest way to get Heroku to support this syntax?
async/await
is part of ES2017, not ES7. – Sumerlin