> For the complete documentation index, see [llms.txt](https://docs.cremawork.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cremawork.com/decelopment/axios-config/apis-calling.md).

# APIs Calling

Crema has some **predefined hooks and functions to call the APIs** without writing redundant code like sending tokens and other extra configurations in APIs. \
\
These functions are directly linked with your authentication method as well, so you don't need anything special to call APIs without any extra setup.

1. **GET**: to fetch the data from the API. We can use this pre-defined hook&#x20;

```javascript
   const [
    {apiData, loading, initialUrl},
    {setData, setLoading, updateInitialUrl, setQueryParams, reCallAPI},
  ] = useGetDataApi('/dashboard/academy', {data: []}, {page: 1, perPage: 10});
```

2. **POST**: To save data using the API function

```javascript

const infoViewActionsContext = useInfoViewActionsContext(); 
 
postDataApi('/wall/posts', infoViewActionsContext, {
    post,
  })
    .then((data) => {
    // Do anything that you want here
      infoViewActionsContext.showMessage('Post Created Successfully!');
    })
    .catch((error) => {
      infoViewActionsContext.fetchError(error.message);
    });

```

3. **PUT**: To save data using the API function

```javascript
const infoViewActionsContext = useInfoViewActionsContext(); 

putDataApi('/wall/posts/${post.id}', infoViewActionsContext, {
    post,
  })
    .then((data) => {
    // Do anything that you want here
      infoViewActionsContext.showMessage('Post Updated Successfully!');
    })
    .catch((error) => {
      infoViewActionsContext.fetchError(error.message);
    });

```

4. **DELETE:** To Delete entry using the API function

<pre class="language-javascript"><code class="lang-javascript"><strong>
</strong>const infoViewActionsContext = useInfoViewActionsContext(); 
<strong>
</strong><strong>deleteDataApi('/wall/posts/${post.id}', infoViewActionsContext)
</strong>    .then((data) => {
    // Do anything that you want here
      infoViewActionsContext.showMessage('Post Deleted Successfully!');
    })
    .catch((error) => {
      infoViewActionsContext.fetchError(error.message);
    });

</code></pre>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.cremawork.com/decelopment/axios-config/apis-calling.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
