# use-promise

### Module

```javascript
import { usePromise } from "@atomico/hooks/use-promise";
```

### Syntax

```jsx
const [result, status] = usePromise(
  asyncFunction,
  runFunction,
  optionalArguments
);
```

Where :

* `result`: Retorno de la promesa
* `status`: Estado de la promesa:
  * `""`: Without executing.
  * `"pending"`: In action.
  * `"fulfilled"`: Successfully executed.
  * `"rejected"`: Executed with error.
* `asyncFunction`: asynchronous function.
* `runFunction`: `Booleano`, if `true` it will execute the promise and define the status.
* `optionalArguments`: Optional `any[]`, allows to regenerate the promise through arguments.

### Example

{% embed url="<https://webcomponents.dev/edit/collection/n2tZyzx4LMKqk1jNE0e9/PWFshi0MYl0CTbwlXIN6/src/index.jsx>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://atomico.gitbook.io/doc/packages/atomico-hooks/use-promise.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
