promise with axios code example

Example 1: AXIOS CDN

<script src="https://unpkg.com/axios/dist/axios.min.js"></script>

Example 2: axios post

axios.post('/user', {
    firstName: 'Fred',
    lastName: 'Flintstone'
  })
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log(error);
  });

Example 3: axios

<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>

Example 4: axios

const axios = require('axios').default;

// axios.<method> will now provide autocomplete and parameter typings

Tags: