Async/Await

JavaScript supports async functions, so does Clio. However, unlike JavaScript Clio doesn’t have an async keyword. Simply using an await keyword in your function marks it as async. The await keyword can be used in flows:

Attention

The fetch function used in the example below is a browser only function, switch to the Node tab to see how you can run this example when targetting Node.

Attention

This example doesn’t run in the playground. To run this example with Node, you need to install node-fetch first. To do so, run the following command in the root directory of your Clio project where your clio.toml is located:

clio deps add --npm node-fetch

It can also be used outside flows:

Attention

The fetch function used in the example below is a browser only function, switch to the Node tab to see how you can run this example when targetting Node.

Attention

This example doesn’t run in the playground. To run this example with Node, you need to install node-fetch first. To do so, run the following command in the root directory of your Clio project where your clio.toml is located:

clio deps add --npm node-fetch

Clio also supports the [await] keyword, which translates to await Promise.all(...):

Attention

The fetch function used in the example below is a browser only function, switch to the Node tab to see how you can run this example when targetting Node.

Attention

This example doesn’t run in the playground. To run this example with Node, you need to install node-fetch first. To do so, run the following command in the root directory of your Clio project where your clio.toml is located:

clio deps add --npm node-fetch