Javascript Ajax Call Using Axios

November 2, 2017

Install axios.

npm install axios --save-dev

Using axios for ajax call.

import axios from 'axios'

axios({
  method: 'post',
  url: '/intents/sync_items',
  data: {
    id: 1,
    name: 'hello'
  }
})
.then((response) => {
  const data = response.data
  console.log(data)
})
.catch((error) => {
  console.log(error)
})
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.