vue:错误:分析错误:意外的令牌

时间:2020-06-10 16:49:47

标签: javascript vue.js

错误:解析错误:意外的令牌

我收到此错误:

parsing error-chrome

parsing error-vscode

但是,错误显示: 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)
      }
    }

1 个答案:

答案 0 :(得分:2)

您缺少功能关键字:

async function fetchUsers (context, userId) {
  // body of function here
}

或者,您可以使用粗箭头语法:

const fetchUsers = async (context, userId) => {
  // body of function here.
}