1. napi_status napi_reject_deferred(napi_env env,
    2. napi_deferred deferred,
    3. napi_value rejection);
    • [in] env: The environment that the API is invoked under.
    • [in] deferred: The deferred object whose associated promise to resolve.
    • [in] rejection: The value with which to reject the promise.

    This API rejects a JavaScript promise by way of the deferred object with which it is associated. Thus, it can only be used to reject JavaScript promises for which the corresponding deferred object is available. This effectively means that the promise must have been created using napi_create_promise() and the deferred object returned from that call must have been retained in order to be passed to this API.

    The deferred object is freed upon successful completion.