javascript - vue:错误:解析错误:意外的令牌
问题描述
错误:解析错误:意外的令牌
我收到了这个错误:
但是,错误显示: 预期的','
const fetchUsers (context, userId) => {
try {
const response = await axios.post('/', {
query: getUsers,
variables: {
id: userId
}
})
console.log('RESP POST:', response.data.data)
console.log(response.data.data.userById)
return response
} catch (error) {
console.log(error)
}
}
解决方案
您缺少 function 关键字:
async function fetchUsers (context, userId) {
// body of function here
}
或者,您可以使用粗箭头语法:
const fetchUsers = async (context, userId) => {
// body of function here.
}
推荐阅读
- kubernetes - 通过服务名称访问 minikube 集群中的 pod 不起作用
- ansible - 稳定 | 如何在角色中调用我的变量
- android - 阻止用户强制停止我的应用程序
- typo3 - 如何从 TSconfig 条件访问扩展配置选项?
- android - Android x 数据绑定
- ruby-on-rails - Sidekiq 部署失败并显示“找不到密钥:“MY_APP_DATABASE_PASSWORD”
- html - 如何使用Angular Js从不同的位置(文件)设置自定义变量
- c# - 正则表达式在字符串中查找用户 UPN
- c# - TCP 服务器在第一条消息后关闭连接
- docker - 如何在同一个 https 域 url 下使用 traefik 服务两个提供商后端