> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cloud.cdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Axios

> This page outlines the steps to connect Axios to your Connect AI account using the REST API.

## Prerequisites

Before you connect, you must first do the following:

* Connect a data source to your Connect AI account. See [Sources](/en/Sources) for more information.
* Generate a Personal Access Token (PAT) on the [Settings](/en/Settings#personal-access-tokens) page. Copy this down, as it acts as your password during authentication.

## Connect to Connect AI with Axios

<Steps>
  <Step>
    Create a project directory, for example, `connect_cloud`.
  </Step>

  <Step>
    Open the terminal in the project directory and initialize a node project as follows:

    ```bash theme={null}
    npm init -y
    ```
  </Step>

  <Step>
    Install the Axios dependency in the project with the following command:

    ```bash theme={null}
    npm install axios
    ```
  </Step>

  <Step>
    In your project directory, create a file called `server.js` that contains the following code. Provide your Connect AI `username` and `pat` (the PAT you created in the prerequisites). You must also provide a `query` for your data, such as `SELECT * FROM Snowflake1.PUBLIC.Accounts`.

    ```javascript expandable theme={null}
    const axios = require('axios')
     const user = 'username'
     const pat = '***********************************';
     //Your API endpoint
     const url = 'https://cloud.cdata.com/api/query';
     //Your data to be sent in the POST request
     const data = {
     "query":"SELECT * FROM Snowflake1.PUBLIC.Accounts"
     };
     axios.post(url, data, {
         auth: {
             username: user,
             password: pat
         }
     })
     .then(response => {
         const rows = response.data.results[0].rows;
         const schema = response.data.results[0].schema;
         //Create an array of column names
         const columnNames = schema.map(col => col.columnName);
         //Loop through each row and log the column name with its value
         rows.forEach(row => {
             const rowObject = {};
             row.forEach((value, index) => {
                 const columnName = columnNames[index];
                 rowObject[columnName] = value;
             });
             console.log(rowObject);
         })
     })
     .catch(error => {
         console.error('Error:', error);
     });
    ```
  </Step>

  <Step>
    In the terminal, execute the following command to run the server:

    ```bash theme={null}
    node server.js
    ```

    The query results appear.

    <Frame>
      <img src="https://mintcdn.com/cdata/dLO4dOBGO5Ysdj01/en/images/axios_client_output.png?fit=max&auto=format&n=dLO4dOBGO5Ysdj01&q=85&s=81eb86c149bcb46ac14d87ab11c0f568" alt="" width="737" height="306" data-path="en/images/axios_client_output.png" />
    </Frame>
  </Step>
</Steps>
