# API Calls

We are using the Axios to make an api call. Here is the global this Axios configuration. You can find it on this path src/@crema/services/auth/jwt-auth/index.js

```typescript
import axios from "axios";

const jwtAxios = axios.create({
  baseURL: "https://BACKEND_SERVER_ATH/api/", // YOUR_API_URL HERE
  headers: {
    "Content-Type": "application/json",
  },
});

jwtAxios.interceptors.response.use(
  (res) => res,
  (err) => {
    if (err.response && err.response.data.msg === "Token is not valid") {
      console.log("Need to logout user");
    }
    return Promise.reject(err);
  }
);
export const setAuthToken = (token) => {
  if (token) {
    jwtAxios.defaults.headers.common.Authorization = `Bearer ${token}`; 
    //You can define any header params like Authorization based on the your requirements
    localStorage.setItem("token", token);
  } else {
    delete jwtAxios.defaults.headers.common.Authorization;
    localStorage.removeItem("token");
  }
};

export default jwtAxios;
```

We are using the mock APIs in our app, to gets the fake data from the Crema fake db. We are using [axios-mock-adapter](https://www.npmjs.com/package/axios-mock-adapter) to achieve this. Here is the configuration of it.

```javascript
import jwtAxios from "../auth/jwt-auth";
const MockAdapter = require("axios-mock-adapter");
export default new MockAdapter(jwtAxios, { delayResponse: 100 });
```


---

# 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://docs.cremawork.com/v-3/development/api-calls.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.
