Build a Twitter Clone With Adonis and Vue

Install and Setup Axios

We'll be using axios as the HTTP client to connect to our API. First, we need to install it:

npm install axios --save

Next, let's set some config defaults for axios which will be applied to every request we make. Open src/main.js and add the code below to it:

// src/main.js

import axios from 'axios'

// add these before Vue is instantiated
window.axios = axios
axios.defaults.baseURL = ''

First, we import axios, then reference it globally so we could use it in other places without having to import it individually in those places. Lastly, we set the baseURL config to our API URL ( so we don't have to add it every time we make a request to our API.

Like this article? Follow @ammezie on Twitter