Jest: Await is a reserved word

Created on 10 Mar 2017  路  4Comments  路  Source: facebook/jest

I have a function navigate that executes the followed code.:

navigate: config => {
    Hype.relations.reduce((relation, nextRelation) => {
      const url = getRelation(relation, config.from).href
      const response = await axios.get(url)

      return response
    })
  }

This error is displayed:
hype/src/hype.js: await is a reserved word

Most helpful comment

You need to add async to your function declaration.

Hype.relations.reduce(async (relation, nextRelation) => {
  const url = getRelation(relation, config.from).href
  const response = await axios.get(url)

  return response
})

All 4 comments

You need to add async to your function declaration.

Hype.relations.reduce(async (relation, nextRelation) => {
  const url = getRelation(relation, config.from).href
  const response = await axios.get(url)

  return response
})

Thanks.

Thanks.

@enapupe thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kgowru picture kgowru  路  3Comments

paularmstrong picture paularmstrong  路  3Comments

stephenlautier picture stephenlautier  路  3Comments

Antho2407 picture Antho2407  路  3Comments

hramos picture hramos  路  3Comments