kazzkiq / CodeFlask

A micro code-editor for awesome web pages.
https://kazzkiq.github.io/CodeFlask/
MIT License
1.07k stars 120 forks source link

Got error passed an async function into .onUpdate #108

Open pea3nut opened 4 years ago

pea3nut commented 4 years ago

https://codepen.io/pea3nut/pen/povXapL

trasherdk commented 4 years ago

What's your problem? Describe problem/error with relevant parts of code. I'm not going to debug for you.

pea3nut commented 4 years ago

Open the codepen and the web devtools bro. Only 2 line code in there.

trasherdk commented 4 years ago

Only 2 line code in there, so you should not have a problem describing your code, and problem here.

kazzkiq commented 4 years ago

CodeFlask .onUpdate() does not supports async functions at the moment.

Since async/await is just syntax sugar on top of Promises, you can still make your code work with .then(). So instead of doing:

flask.onUpdate(async () => {
  const data = await yourAsyncFunctionHere();
 // do something with "data" here
});

You can simply do:

flask.onUpdate(() => {
  yourAsyncFunctionHere().then(data => {
    // do something with "data" here
  });
});