CodeFlask icon indicating copy to clipboard operation
CodeFlask copied to clipboard

Got error passed an async function into .onUpdate

Open pea3nut opened this issue 5 years ago • 4 comments

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

pea3nut avatar Jan 31 '20 11:01 pea3nut

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

trasherdk avatar Jan 31 '20 16:01 trasherdk

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

pea3nut avatar Jan 31 '20 16:01 pea3nut

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

trasherdk avatar Jan 31 '20 17:01 trasherdk

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
  });
});

kazzkiq avatar Jun 04 '20 20:06 kazzkiq