I am trying to do an axios request but whatever I do I get the same error message.
The message is:
Parsing error: Unexpected token, expected ",". The error points at axios.get (it points at the dot between "axios" and "get" in the error message). It gives the same message if I put something like console.log in the code.
I am basically just using a regular default vue project and the only thing I have done is to add the following code in HelloWorld.vue.
<script type="text/javascript">
import axios from 'axios';
// const axios = require('axios');
export default {
name: 'HelloWorld', // console.log("hi"),
props: {
msg: String //response
},
methods: {
axios.get('https://swapi.co/api/people/1')
.then(function(response){
console.log(response)
})
}
}
</script>
Can someone please tell me why this error keeps coming up, I am guessing this is pretty simple but I am losing my mind at this point. Thank you
methodsobject lacks the keyname and function operator. I.e. you've written the body of the method directly inside the object.