Skip to main content
edited tags
Link
T.J. Crowder
  • 1.1m
  • 19
  • 110
  • 139
(While we are at it.) - yes, I did not bump it (that was by an answer edit!). [<https://en.wikipedia.org/wiki/Sentence_clause_structure#Run-on_sentences>]. Expanded. Added information from comments.
Source Link
Peter Mortensen
  • 31.6k
  • 4
  • 22
  • 14

Why won't the following snippet work here on Stack Overflow?

I'm trying to add some example of basic async/await and returned promises.

This exact same piece of code works just fine on my devdevelopment environment,. I'm using BabelBabel, but I've seen snippets with async await functions here on SOStack Overflow before.

What's happening?

It gives the error:

{
  "message": "Script error.",
  "filename": "",
  "lineno": 0,
  "colno": 0
}

function bar() {
  return new Promise((resolve,reject) => {
    setTimeout(()=> {
      resolve('resolved after 1500ms');
    },1500);
    // return resolve('resolved');
  });
}

async function foo() {
  const result = await bar();
  console.log(result);
}

foo();

I'm on Chrome version 75.0.3770.80 (official build) (64-bit).

Why won't the following snippet work here on Stack Overflow?

I'm trying to add some example of basic async/await and returned promises.

This exact same piece of code works just fine on my dev environment, I'm using Babel, but I've seen snippets with async await functions here on SO before.

What's happening?

It gives the error:

{
  "message": "Script error.",
  "filename": "",
  "lineno": 0,
  "colno": 0
}

function bar() {
  return new Promise((resolve,reject) => {
    setTimeout(()=> {
      resolve('resolved after 1500ms');
    },1500);
    // return resolve('resolved');
  });
}

async function foo() {
  const result = await bar();
  console.log(result);
}

foo();

Why won't the following snippet work here on Stack Overflow?

I'm trying to add some example of basic async/await and returned promises.

This exact same piece of code works just fine on my development environment. I'm using Babel, but I've seen snippets with async await functions here on Stack Overflow before.

What's happening?

It gives the error:

{
  "message": "Script error.",
  "filename": "",
  "lineno": 0,
  "colno": 0
}

function bar() {
  return new Promise((resolve,reject) => {
    setTimeout(()=> {
      resolve('resolved after 1500ms');
    },1500);
    // return resolve('resolved');
  });
}

async function foo() {
  const result = await bar();
  console.log(result);
}

foo();

I'm on Chrome version 75.0.3770.80 (official build) (64-bit).

edited tags
Link
Donald Duck
  • 8.8k
  • 4
  • 37
  • 59
Name of the site is two words; gammar
Source Link
Heretic Monkey
  • 12.1k
  • 5
  • 49
  • 70
Loading
Post Migrated Here from stackoverflow.com (revisions)
Source Link
cbdeveloper
  • 31.1k
  • 7
  • 7
Loading