意味着更新不能从服务,只从邮递员
我想通过服务进行更新。如果我使用与服务中链接相同的邮递员,更新可以正常工作。意味着更新不能从服务,只从邮递员
这里是我的代码:
myservice.service.ts:
updateUser(userid){     let headers = new Headers(); 
    headers.append('Content-Type','application/json'); 
    console.log('http://localhost:3000/users/update/'+ userid); 
    return this.http.put('http://localhost:3000/users/update/'+ userid, 
{headers: headers}).map(res => res.json()); 
} 
内航线/ users.js
router.put('/update/:id', (req, res) => { User.findByIdAndUpdate(req.params.id, { 
$set: { 
    participates: true} 
}, 
{ 
    new: true 
}, 
function(err, updatedUser){ 
    if(err){ 
    res.send("Error updating user"); 
    } else{ 
    res.json(updatedUser); 
    } 
} 
); 
}); 
我没有得到一个错误,但它不似乎进入router.put。 我错过了什么?
回答:
这里你已经使用这个网址: 'http://localhost:3000/users/update/' +用户ID
但路线已使用:/更新/:身份证,
你有/用户是不是有你路线, 只需使用相同的URL,你的服务提到的将是很好的航线使用,所以用/用户/更新/更换路线您的网址:ID,那么它会很好地工作..
以上是 意味着更新不能从服务,只从邮递员 的全部内容, 来源链接: utcz.com/qa/260869.html





