Javascript React Redux语法错误“&引用;预期

Javascript React Redux语法错误“&引用;预期,javascript,reactjs,react-redux,Javascript,Reactjs,React Redux,这是新的 …这可能很简单。我查看了const“selectData”的代码,但找不到逗号应该放在哪里。以下是整个文件: export const requestLoginToken = (username, password) => (dispatch, getState) => { dispatch({ type: REQUEST_LOGIN_TOKEN, payload: username }) const payload = { userNam

这是新的

…这可能很简单。我查看了const“selectData”的代码,但找不到逗号应该放在哪里。以下是整个文件:

export const requestLoginToken = (username, password) =>
  (dispatch, getState) => {
    dispatch({ type: REQUEST_LOGIN_TOKEN, payload: username })

    const payload = {
      userName: username,
      password: password,
    }

    const task = fetch('/api/jwt', {
      method: 'POST',
      body: JSON.stringify(payload),
      headers: {
        'Content-Type': 'application/json;charset=UTF-8'
      },
    })
      .then(handleErrors)
      .then(response => response.json())
      .then(data => {
        dispatch({ type: RECEIVE_LOGIN_TOKEN, payload: data })
        saveJwt(data)

        selectData()

      })
      .catch(error => {
        clearJwt()
        dispatch({ type: ERROR_LOGIN_TOKEN, payload: error.message })
      })
    addTask(task)
    return task
  }

const selectData = () => {
  dispatch({ type: REQUEST_SELECT_DATA })

  const token = jwt.access_token
  const headers = new Headers({
    'Authorization': `Bearer ${token}`
  })
  const selectData = fetch('/api/SelectData/SelectData', {
    method: 'GET',
    headers,
  })
    .then(handleErrors)
    .then(response => response.json())
    .then(data => {
      dispatch({ type: RECEIVE_SELECT_DATA, payload: data })
        .catch(error => {
          clearJwt()
          dispatch({ type: ERROR_SELECT_DATA, payload: error.message })
        })
    }
}
错误出现在最后一个花括号上,上面写着:

意外令牌,应为(72:0)

第72行是最后一个花括号

如果我删除“selectData”的常量表达式,它是OK-没有错误。只有在我添加代码块时才会出现错误。。。i、 e其内容如下:

const selectData = () => {
  dispatch({ type: REQUEST_SELECT_DATA })

  const token = jwt.access_token
  const headers = new Headers({
    'Authorization': `Bearer ${token}`
  })
  const selectData = fetch('/api/SelectData/SelectData', {
    method: 'GET',
    headers,
  })
    .then(handleErrors)
    .then(response => response.json())
    .then(data => {
      dispatch({ type: RECEIVE_SELECT_DATA, payload: data })
        .catch(error => {
          clearJwt()
          dispatch({ type: ERROR_SELECT_DATA, payload: error.message })
        })
    }
}
为什么这段代码会导致错误?

您在最后一次
时忘记了
,然后

.then(data => {
  dispatch({ type: RECEIVE_SELECT_DATA, payload: data })
    .catch(error => {
      clearJwt()
      dispatch({ type: ERROR_SELECT_DATA, payload: error.message })
    })
}) // <--- here
。然后(数据=>{
分派({type:RECEIVE\u SELECT\u DATA,payload:DATA})
.catch(错误=>{
clearJwt()
分派({type:ERROR\u SELECT\u DATA,payload:ERROR.message})
})

})//我原以为a-1是最基本的,但我一生都找不到它。。干杯下一次使用短绒,大多数编辑器都可以与之集成。