[Vuejs]-Pass the url of the current domain in axios VueJS

0๐Ÿ‘

โœ…

1) Create a separate file with a const containing this base url.

2) export this const

3) use it wherever you want

// consts.js

export const BASE_URL = 'http://prestashop_1_6.local';


// Any file that consume it.
import {BASE_URL} from './consts';

data() {
  return {
    url: `${BASE_URL}/something/something-else`
  };
}

Leave a comment