Ich versuche ein bestehendes Dokument in mongodb mit node.js zu aktualisieren. Aber es scheint nicht zu funktionieren. Es zeigt den Anforderungsaufruf nicht einmal in der Konsole an. Bitte schlagen Sie vor, welchen Fehler ich mache oder wie ich den Update-Vorgang in node.js mit mongodb durchführen kann. Hier ist der Code:PUT Anfrage funktioniert nicht in Node.js
Node.js Code:
app.put('/addIssueId', function(req, res) {
console.log("Adding issue id")
console.log(req.body.issueKey)
impactMapFeature.update({productName:req.params.productName, actor:req.body.actor, activity:req.body.activity,feature:req.body.feature},{issueKey:req.body.issueKey}, function (err, data) {
console.log("Updating" + data)
});
});
Winkelregler Code:
var data = {
productName: $scope.productName,
actor: actor,
activity: impact,
feature : $('#feature').val(),
issueKey : data.key
};
$http.put('/addIssueId', data)
.success(function(data){
}).error(function(data){
console.log('Error in adding issueId' + data)
});
}
zu ändern, wenn nicht '{ productName: req.params.productName, ...} 'be' {Produktname: req.body.productName, ...} '? – chridam
Es scheint zu funktionieren, aber warum ich nicht ähnlich wie PUT/addIssueId 200 17ms in der Konsole wie ich es für POST/GET/DELETE bekomme –
Es ist, weil 'req.params' für die route-Parameter ist, nicht für deine Daten, daher fehlt dir der 'productName' route Parameter' app.put ('/addIssueId /: productName ',. .' und auf dem Client als '$ http.put ('/ addIssueId /' + $ scope.productName, ...' – chridam