Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/466.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 Can';无法让删除http请求正常工作_Javascript_Angularjs_Node.js_Postgresql - Fatal编程技术网

Javascript Can';无法让删除http请求正常工作

Javascript Can';无法让删除http请求正常工作,javascript,angularjs,node.js,postgresql,Javascript,Angularjs,Node.js,Postgresql,我正在尝试让删除http请求正常工作。我在前端使用AngularJS,在后端使用Node.js和PostgreSQL 我希望能够根据会话id删除会话,但由于某些原因,它只删除1的id,而不删除其他id 所以如果我有 id 1 id 2 id 3 我的删除请求将删除id 1,但对其他id无效 这是我的密码 HTML 控制器 $scope.cancelUserSession = (userId) => { const subtracting = currentIndex - 1;

我正在尝试让删除http请求正常工作。我在前端使用AngularJS,在后端使用Node.js和PostgreSQL

我希望能够根据会话id删除会话,但由于某些原因,它只删除1的id,而不删除其他id

所以如果我有

id 1 id 2 id 3

我的删除请求将删除id 1,但对其他id无效

这是我的密码

HTML

控制器

   $scope.cancelUserSession = (userId) => {
    const subtracting = currentIndex - 1;
  if (subtracting <= 0) {
      swal({
        title: "Cancel Session",
        type: "warning",
        showCancelButton: true,
        confirmButtonText: "Cancel",
        cancelButtonText: "Keep",
        animation: "slide-from-top"
      },
      () => {
      loginService.cancelUserSession(userId).then((response) => {
        console.log(response);
        console.log("session canceled")
        getSessions();
      })
    })
  }
  };
index.js

 app.delete('/remove-session/:userId', userCtrl.userCancelSession);
用户控制

    userCancelSession: (req, res) => {
    app.get('db').delete_client_session([req.params.userId]).then(response => {
      res.status(200).send(response + "item removed succesfully")
    }).catch(err => console.log(err))
  },
SQL


您可以记录userCtrl中的req.params.userId吗?是的,每次控制台都会记录1。
 app.delete('/remove-session/:userId', userCtrl.userCancelSession);
    userCancelSession: (req, res) => {
    app.get('db').delete_client_session([req.params.userId]).then(response => {
      res.status(200).send(response + "item removed succesfully")
    }).catch(err => console.log(err))
  },
delete from client_sessions
  where client_sessions.id = $1;