首页 > 解决方案 > .then(Response => SyntaxError: Unexpected token ., in Vue js

问题描述

我目前正在学习 Vue 并学习 Udemy 课程。然而,我的空 Vue 项目在符号上比我的老师更严格一些。因此,当我试图弄清楚这一切时,我有时也会遇到意外的令牌错误。

我真的不明白为什么我会在 .then 上收到意外的令牌错误。这可能是一件非常简单的事情,我还不认为这是一个错误。

我检查了所有内容以查看是否所有内容都有结束标签、逗号和分号。

actions: {
    signIn({ commit }, payload) {
      Vue.http.post(`${FbAuth}/verifyPassword?key=${FbApiKey}`, {
        ...payload,
        returnSecureToken: true,
      }),
      .then( response => response.json())
      .then( authData =>  {
        console.log(authData);
      }),
    },
  },

它应该通过登录操作并检查我的 firebase 数据库以获取所需的凭据。

标签: vue.js

解决方案


点之前有一个逗号。
试试下面的代码:

    actions: {
        signIn({ commit }, payload) {
          Vue.http.post(`${FbAuth}/verifyPassword?key=${FbApiKey}`, {
            ...payload,
            returnSecureToken: true,
          })
          .then( response => response.json())
          .then( authData =>  {
            console.log(authData);
          }),
        },
      },

推荐阅读