Can I import Axios into Mixins ? I have a Rest API and am putting in a Mixin my GET code, but I use Axios for this. When I try to import Axios into Mixins , it returns me:
Uncaught SyntaxError: Unexpected token import at MyMixins.js: 1
MyMixins.js
import axios from 'axios'
let getMixins = {
created() {
axios.get('https://api.myjson.com/bins/17rqo1')
.then(response => {
console.log( response )
})
.catch(e => {
// Errors
})
}
}
List.vue
<template>
<h1> Test Mixins <h1>
</template>
<script>
import axios from 'axios'
export default {
data: () => ({
dataItem: [],
errors: []
}),
mixins: [getListagem]
}
</script>
What am I doing wrong? I am creating simple variable with .js because I would not like to use
'import myMixins from ./myMixins'
in my .vue
Is there any way you can do this?
Thank you!