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

# JavaScript

> Learn how to use JavaScript to make requests with proxies.

<Accordion title="axios" defaultOpen>
  <CodeGroup>
    ```JavaScript axios theme={null}
    const axios = require('axios');

    const proxyConfig = {
      protocol: 'http',
      host: 'proxy.antsdata.com',
      port: 40000
      auth: {
        username: 'your_proxy_username',
        password: 'your_proxy_password'
      }
    };

    const config = {
    proxy: proxyConfig
    };

    const target_url = 'https://httpbin.org/ip'

    axios.get(target_url, config)
    .then(response => {
      console.log(response.data);
    })
    .catch(error => {
      console.error('Error during request:', error);
    });
    ```

    ```JavaScript https-proxy-agent theme={null}
    const axios = require('axios');
    const { HttpsProxyAgent} = require('https-proxy-agent');

    const proxy_username = 'your_proxy_username'
    const proxy_password = 'your_proxy_password'
    const proxyAgent = new HttpsProxyAgent(`http://${proxy_username}:${proxy_password}@proxy.antsdata.com:40000`)

    const config = {
      httpAgent: proxyAgent,
      httpsAgent: proxyAgent
    };

    const target_url = 'https://httpbin.org/ip'

    axios.get(target_url, config)
    .then(response => {
      console.log(response.data);
    })
    .catch(error => {
      console.error('Error during request:', error);
    });
    ```
  </CodeGroup>
</Accordion>

<Accordion title="playwright">
  ```Javascript playwright theme={null}
  const { chromium } = require('playwright');

  const proxyConfig = {
    server: 'http://proxy.antsdata.com:40000',
    username: 'your_proxy_username',
    password: 'your_proxy_password'
  }

  const config = {
    proxy: proxyConfig
  };

  const target_url = 'https://httpbin.org/ip'

  async function fetchData(target_url, config) {
    const browser = await chromium.launch(config);
    const page = await browser.newPage();
    await page.goto(target_url);
    const content = await page.locator('pre').innerText();
    console.log(content);
    await browser.close();
  }

  fetchData(target_url, config)
  ```
</Accordion>
