I use this tutorial: https://alligator.io/vuejs/rest-api-axios/ And tried to use axios like this: in my main.js file:
import axios from 'axios'
export const HTTP = axios.create({
baseURL: `http://api.com/api/`,
headers: {
// Authorization: 'Bearer {token}'
}
})
And in my .vue file:
import {HTTP} from './http-common';
let params = {
email: this.login,
pwd: this.pwd
}
HTTP.post(`login`, params)
.then(response => {
alert(response);
})
.catch(e => {
this.errors.push(e)
})
ERROR in ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0&bustCache!./src/components/SignIn.vue Module not found: Error: Can't resolve './http-common' in 'C:\Users\direwolf\Documents\web\js\vue\quasar-crm\src\components' @ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0&bustCache!./src/components/SignIn.vue 5:0-37 @ ./src/components/SignIn.vue @ ./src/router.js @ ./src/main.js @ multi ./build/hot-reload.js ./src/main.js