Skip to content

[question] async call in constructor #4632

Closed
@Inve1951

Description

@Inve1951

this is my first time trying to use await/promises

in a class constructor i put this:

if await new Promise (r) =>
  cache.get @url, (b) =>
    r b
    return
  return
then return

since that gave me error: Class constructor may not be async when compiling i tried to work around it by wrapping it with do =>:

do =>
  if await new Promise (r) =>
    cache.get @url, (b) =>
      r b
      return
    return
  then return

which throws at runtime with Uncaught SyntaxError: Unexpected token ( after async
i get the same result when adding a space after async

so my question is, what am i doing wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions