Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/440.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 是否可以从reactjs向expressjs发送post请求,并在express中获取数据,然后使用redux将其发送回reactjs?_Javascript_Reactjs_Express_Redux - Fatal编程技术网

Javascript 是否可以从reactjs向expressjs发送post请求,并在express中获取数据,然后使用redux将其发送回reactjs?

Javascript 是否可以从reactjs向expressjs发送post请求,并在express中获取数据,然后使用redux将其发送回reactjs?,javascript,reactjs,express,redux,Javascript,Reactjs,Express,Redux,我是新来的 在我的场景中,我有一个输入字段,我使用该输入字段填充post请求的主体: Action ===> export const fetchSearchProducts = (search) => (dispatch) => { fetch("/search", { method: "POST", headers: { "Content-Type": "appli

我是新来的

在我的场景中,我有一个输入字段,我使用该输入字段填充post请求的主体:

Action ===> export const fetchSearchProducts = (search) =>  (dispatch) => {


   fetch("/search", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    body: JSON.stringify(search),
  })
    .then((res) => res.json())
    .then((data) => {
      dispatch({ type: FETCH_SEARCH_ITEM, payload: data }); ===> this errors out saying Unhandled Rejection (TypeError): dispatch is not a function


      // this console.log() actually returns the data im looking for
      console.log(data)
      
    });
  };
这篇文章转到ExpressJS服务器,在那里我使用“req.body.search”填充API获取的url字段。“url=
https://example.nl?search=${req.body.search}
;”

到目前为止,它似乎一直在起作用


现在我的问题是,我正在尝试使用操作中的redux分派填充状态。。。。。但我一直遇到这样的错误:未处理的拒绝(TypeError):分派本身不是一个函数,redux不支持异步分派,需要一个中间件来完成。您可以添加任何允许异步调度的中间件,如redux thunk或类似的库

有关这方面的详细信息,您可以查看