File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -75,5 +75,47 @@ Rejects the Promise object held by the `Napi::Promise::Deferred` object.
7575
7676* ` [in] value ` : The Node-API primitive value with which to reject the ` Napi::Promise ` .
7777
78+ ## Promise Methods
79+
80+ ### Then
81+
82+ ``` cpp
83+ <Promise> Napi::Promise::Then (napi_value onFulfilled, napi_value onRejected) const;
84+ ```
85+
86+ Attaches fulfillment and/or rejection handlers to the promise and returns a new promise.
87+
88+ **Parameters:**
89+ * `[in] onFulfilled`: A function to be called when the promise is fulfilled
90+ * `[in] onRejected`: A function to be called when the promise is rejected (optional)
91+
92+ **Returns:** A new `<Promise>` that resolves or rejects based on the handler's result.
93+
94+ **Example:**
95+ ```cpp
96+ // Single fulfillment handler
97+ Promise newPromise = existingPromise.Then(fulfillmentHandler);
98+
99+ // Both fulfillment and rejection handlers
100+ Promise chainedPromise = existingPromise.Then(onFulfilled, onRejected);
101+ ```
102+
103+ ### Catch
104+
105+ ``` cpp
106+ <Promise> Napi::Promise::Catch (napi_value onRejected) const;
107+ ```
108+
109+ Attaches a rejection handler to the promise and returns a new promise.
110+
111+ **Parameters:**
112+ * `[in] onRejected`: A function to be called when the promise is rejected
113+
114+ **Returns:** A new `<Promise>` that handles rejection cases.
115+
116+ **Example:**
117+ ```cpp
118+ Promise handledPromise = existingPromise.Catch(rejectionHandler);
119+ ```
78120
79121[ `Napi::Object` ] : ./object.md
You can’t perform that action at this time.
0 commit comments