Express 使用同构获取发布身份验证表单的正确方法是什么?

Express 使用同构获取发布身份验证表单的正确方法是什么?,express,reactjs,fetch,redux,isomorphic-fetch-api,Express,Reactjs,Fetch,Redux,Isomorphic Fetch Api,我使用以下代码从调用express POST端点的react/redux应用程序发送ajax请求。 我很确定问题不在服务器端,因为我已经用Postman测试了这个端点,它工作正常。 这就是我在客户端使用的代码,它从passport身份验证返回{message:“缺少凭据”}。。。同样,服务器上没有问题。。。我正确地使用了bodyparser,注销了req.body.email和req.body.password——它们是使用Postman正确打印的,但是使用同构提取和以下代码启动此调用是在服务器

我使用以下代码从调用express POST端点的react/redux应用程序发送ajax请求。
我很确定问题不在服务器端,因为我已经用Postman测试了这个端点,它工作正常。 这就是我在客户端使用的代码,它从passport身份验证返回
{message:“缺少凭据”}
。。。同样,服务器上没有问题。。。我正确地使用了bodyparser,注销了
req.body.email
req.body.password
——它们是使用Postman正确打印的,但是使用同构提取和以下代码启动此调用是在服务器上打印以下
req.body

{ '------WebKitFormBoundaryKtn3SHumfq4YBeZ1\r\nContent-Disposition: form-data; name': '"email"\r\n\r\ntest@domain.com\r\n------WebKitFormBoundaryKtn3SHumfq4YBeZ1\r\nContent-Disposition: form-data; name="password"\r\n\r\ntestPassword\r\n------WebKitFormBoundaryKtn3SHumfq4YBeZ1--\r\n' }


import fetch    from 'isomorphic-fetch'
import FormData from 'form-data'

export function signup(payload) {

    return (dispatch) => {

        let formData = new FormData()
        formData.append('email',payload.email)
        formData.append('password',payload.password)

        fetch(`${baseURL}/signup`, {
          method: 'post',
          body: formData,
          headers: new Headers({
            'content-type': 'application/x-www-form-urlencoded; charset=utf-8',
            'Accept': 'application/json, application/xml, text/plain, text/html, *.*'
          }),
        })
        .then((res) => res.json())
        .then((res) => {
            console.log('Fetch signup result:',res)
            console.log('dispatch:',dispatch)
            dispatch({
                type        : Auth_Actions.SignUp_Success,
                userObject  : res
            })
        })
        .catch((err)=>{
            console.error('Fetch signup ERROR:',err)
            dispatch({
                type        : Auth_Actions.SignUp_Fail,
                userObject  : err
            })
        });

    }
}

您是否尝试添加您的授权令牌?标题中的类似内容:

  headers: {
    'Accept': 'application/json',
    'Authorization': token.id,
    'Content-Type': 'application/json'
  }

您是否尝试添加您的授权令牌?标题中的类似内容:

  headers: {
    'Accept': 'application/json',
    'Authorization': token.id,
    'Content-Type': 'application/json'
  }