成功加入节点js后删除请求

时间:2020-09-24 10:33:57

标签: node.js

这是脚本:

function accept(id,value){
    $.ajax({
        url:'/accept',
        method:'POST',
        dataType:'JSON',
        data:{id:id,value:value},
        success:function(doc){
            var id=doc._id;
            $.ajax({
            url: "/remove",
            type: "post",
            data: {id:id},
            success: function (data) {
            }
        });






this is index.js:

post('/ remove',function(req,res,next){

var id = req.body.id;

var removeata = reqmodel.findByIdAndDelete(id);

removedata.exec(function(err){

  if (err) throw err;  
});




















and error is:

reqmodel.findByIdAndDelete不是函数**

1 个答案:

答案 0 :(得分:0)

var removeata = reqmodel.findByIdAndDelete(id)

替换为

var removeata = reqmodel.findByIdAndRemove(id)