错误:解析错误:意外的令牌
我收到此错误:
但是,错误显示: expected ','
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)
}
}
答案 0 :(得分:2)
您缺少功能关键字:
async function fetchUsers (context, userId) {
// body of function here
}
或者,您可以使用粗箭头语法:
const fetchUsers = async (context, userId) => {
// body of function here.
}