Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/458.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 在1个提交表单上发送2个值_Javascript_Reactjs_React Redux - Fatal编程技术网

Javascript 在1个提交表单上发送2个值

Javascript 在1个提交表单上发送2个值,javascript,reactjs,react-redux,Javascript,Reactjs,React Redux,如何在一个函数fetchCalendar()中提交两个不同的值 现在我只能通过期限(周)和get请求,但我还需要通过API的期限(周)和用户(id)。因此,请求应如下所示: `${ROOT_URL}${week}/users/id 现在,我的用户id是常量const user=1,我希望有机会从公式中传递它。因此,我希望fetchCalendar具有2个参数,week+用户ID,其中这2个值来自一个提交表单上的2个独立输入。re轻松地将用户作为prop传递的方法尝试将两个输入处理程序(而不是一

如何在一个函数fetchCalendar()中提交两个不同的值

现在我只能通过期限(周)和get请求,但我还需要通过API的期限(周)和用户(id)。因此,请求应如下所示:

`${ROOT_URL}${week}/users/id

现在,我的用户id是常量const user=
1
,我希望有机会从公式中传递它。因此,我希望fetchCalendar具有2个参数,week+用户ID,其中这2个值来自一个提交表单上的2个独立输入。re

轻松地将用户作为prop传递的方法尝试将两个输入处理程序(而不是一个)装箱,并修改id和term的两种状态,然后可以在函数中同时传递这两种状态。好的,我用两个输入来处理它。感谢you@P4TRYK,也可以使用输入隐藏;)
export function fetchCalendar(week) {
  const url = `${ROOT_URL}${week}/users/${USER}`;
  const request = axios.get(url)
  .catch(function (error) {
    if (error.response) {
      alert('This weekend is out of range of our API and wouldnt be displayed!')
    }
  });
  return {
    type: FETCH_CALENDAR,
    payload: request 
  };
}
`${ROOT_URL}${week}/users/id