目录

Calling an ArkTS Method with Return Value of a promise Using Node-API

When to Use

You can call the ArkTS APIs, which return a promise, in the created ArkTS runtime environment as follows:

Calling an ArkTS Method Asynchronously

Use C++ to call the ArkTS method that returns a promise through the Node-API.

Bind the Promise object to a C++ callback to process the result returned asynchronously.

Convert data types: Convert the JavaScript result to C++-usable data in the callback.

[h2]Sample Code