Axios

v1.21.0

Promise based HTTP client with interceptors, timeouts and automatic JSON handling.

Quick start

Add this tag to your page. Place it just before the closing </body> tag, or in the <head> with the defer attribute.

HTML
<script src="https://jscdns.net/libs/axios/1.21.0/axios.min.js"
        integrity="sha384-p5EwRuz37ylAY9QrjGGIs9ngKVaIwppUFSourks9EIRp1CzoIDWoQkXrHxaAUhEB" crossorigin="anonymous"></script>

Files

FileSizeCopy
axios.min.jsScript 75.1 KB
esm/axios.min.jsES module 57.5 KB

Usage

Complete example

A minimal page that loads Axios and uses it. Copy it into a file and open it in your browser.

example.html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
</head>
<body>
  <pre id="result">Loading...</pre>

  <script src="https://jscdns.net/libs/axios/1.21.0/axios.min.js"
          integrity="sha384-p5EwRuz37ylAY9QrjGGIs9ngKVaIwppUFSourks9EIRp1CzoIDWoQkXrHxaAUhEB" crossorigin="anonymous"></script>
  <script>
    axios.get('https://jsonplaceholder.typicode.com/users/1', { timeout: 5000 })
      .then(function (response) {
        document.querySelector('#result').textContent =
          JSON.stringify(response.data, null, 2);
      })
      .catch(function (error) {
        console.error('Request failed:', error.message);
      });
  </script>
</body>
</html>

Using the ES module build

If your page already uses <script type="module">, you can import the module build directly instead of relying on a global variable.

module.html
<script type="module">
  import axios from 'https://jscdns.net/libs/axios/1.21.0/esm/axios.min.js';

  const { data } = await axios.get('https://jsonplaceholder.typicode.com/users/1');
  console.log(data);
</script>
Good to know. Requests made from the browser are still subject to the CORS policy of the API you are calling.