[英]Unexpected token in axios get request
我是vue.js的新手,正在尝试使用axios进行GET调用,但出现错误:
<script>
import axios from 'axios';
export default {
name: 'AboutMe',
data () {
return {
profile: {},
}
},
computed: {
token () {
return this.$store.getters.getToken;
},
BASE_URL () {
return this.$store.state.BASE_URL;
},
userid () {
return this.$store.getters.getUserid;
},
},
created: {
axios.get(this.BASE_URL + "/profile/aboutme/" + this.userid )
.then( res => {
console.log.(res.data);
})
.catch( error => { });
}
}
</script>
但是我得到这个讨厌的错误:
SyntaxError: /home/me/vue-myapp/src/components/AboutMe.vue: Unexpected token, expected "," (121:9)
119 |
120 | created: {
> 121 | axios.get(this.BASE_URL + "/profile/aboutme/" + this.userid )
| ^
122 | .then( res => {
123 | console.log.(res.data);
124 |
这确实令人困惑,因为一切似乎都很正常。 感谢您的提示以解决此问题。
你出乎意料.
在console.log.(res.data);
。 它应该是console.log(res.data);
该对象也格式不正确。 应该是这样的:
created: {
axios.get(this.BASE_URL + "/profile/aboutme/" + this.userid )
.then( res => {
console.log.(res.data);
})
.catch( error => { })
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.