'import' and 'export' may only appear at the top level. (6:2) error

I am new at vuejs.
I created a component and I import axios but I have this error

‘import’ and ‘export’ may only appear at the top level. (6:2).

What is wrong?
This is my code (Hellowword.vue) at script tag

 import axios from "axios";
export default {
  data() {
    return {
        mcat:'',
     categories: []
    }
  },
   created() {
    axios.get('http://localhost/vueass/cats.json')
    .then(response => {
        alert('ok');
         this.categories = response.data.cats;
    })
    .catch(error => {
      console.log(error);
    })
}
}

I solved it, I had an error.
Thank you.

1 Like