(Node JS) SyntaxError: Unexpected token function for async function
So I am trying to use async / await, but I am getting this error:
async function something(options) {
^^^^^^^^
SyntaxError: Unexpected token function
Here's the code:
var request = require('superagent');
async function something(options) {
let response = await request.get("apiurlblabla");
if(response) {
.query(({'queryqeureur}))
.query(({'uqeryqery'}))
var jsonString = JSON.parse(res.text)
console.log(jsonString.propertyblabla);
console.log(jsonString.propertyblabla)
}
}
+3
SpecialVirusTasker
source
to share
2 answers
The async feature is officially supported in nodejs 8 and later. you must update your nodejs version to 8 or newer.
+6
Kermit
source
to share
Install node version manager:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash
Install the new version of node:
nvm install 8.0
Update version that uses:
nvm use 8.0
0
Sergey Pavlov
source
to share