I have been attempting to make an axios request, but no matter what I try, I keep encountering the same error message.
The specific error message reads:
Parsing error: Unexpected token, expected ","
. The error specifically points to axios.get (highlighting the period between "axios" and "get" in the error). This error persists even if I use something like console.log
in the code.
I am simply working with a standard default vue project, and the only modification I have made is adding the following code into 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>
If someone could kindly explain why this error persists, I would greatly appreciate it. I assume it's something simple, but at this point, it's driving me crazy. Thank you.