0
Düğüm içinde mevcut bir belgeyi node.js. ile güncellemeye çalışıyorum. Ama işe yaramıyor. İstek çağrısını konsolda bile göstermez. Lütfen hangi hatayı yaptığımı veya node.js'de mongodb ile güncelleme işlemini nasıl yapabileceğimi önerin. İşte kod:PUT isteği çalışmıyor Node.js
node.js Kodu:
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)
});
});
Eğik Kontrolör kodu: Bir rota parametredir
chridam söylediği gibivar 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)
});
}
olmamalı '{üzere
req.params.productName
değiştirmeniz gerekir/addIssueId?productName=productName
ve{productName = req.query.productName, ... }
veya değişken geçirmek:/addIssueId/:productName
veya bir sorgu parametresi ile değişken geçirmek: Ya şu rotayı kullanmak productName: req.params.productName, ...} 'be' {productName: req.body.productName, ...} '? – chridamÇalışıyor gibi görünüyor, ancak neden konsolda PUT/addIssueId 200 17ms'ye benzemiyorum POST/GET/DELETE –
için aldığım gibi, 'req.params', rota parametreleri için değil, verileriniz değil, bu nedenle 'productName' yol parametresi 'app.put ('/addIssueId /: productName ',) eksiksinizdir. . 've istemci üzerinde $ http.put ('/ addIssueId /' + $ scope.productName, ...' – chridam