Ich würde Verwendung UPDATE Pfosten mögen, aber ich nicht erhalten die Anfrage mit der gut app.postwie Multiple POST verwenden angujarjs Knoten
Der Antrag mit $ scope.UPDATE gesendet wird, aber ich erhalte eine Antwort von add.post (OMG), nicht von michel!
In der Konsole erhalte ich Antwort von OMG, nicht michel. warum und wie zu lösen dieses
Controller:
$scope.add = function (contact) {
var omg = JSON.stringify(contact);
console.log(omg);
$http.post('/contactlist/' + omg).then(function (response) {
refresh();
});
};
$scope.update = function (contact) {
var michel = JSON.stringify(contact);
$http.post('/contactlist/' + michel).then(function (response) {
console.log(response);
refresh();
});
};
Server-Seite:
app.post('/contactlist/:omg', function (req, res) {
var omg = req.params.omg;
var test = JSON.parse(omg);
console.log(omg);
// var name = JSON.parse(omg, 1);
var array = [ [test.name, test.email, test.number] ];
connection.query('INSERT INTO contactlist (name, email, number) VALUES ?', [array], function (error, results, fields) {
res.json();
});
});
app.post('/contactlist/:michel', function (req, res) {
console.log("testtestetstest");
res.json();
});
Danke, es funktioniert –