3

So I'm trying to use async/await but i get 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)
    }
}

2 Answers2

7

async function is supported officially in nodejs 8 and later. you should update your nodejs version to 8 or later.

Kermit
  • 1,062
  • 6
  • 10
1

Install node version manager:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash

Install new version of node:

nvm install 8.0

Update verion which uses:

nvm use 8.0
Sergey Pavlov
  • 289
  • 3
  • 8