das ist mein HTTP-Dienst hier:Angular2. HTTP.POST funktioniert nicht
postData(name, country) {
var body = JSON.stringify({
"name":name,
"country":country
});
console.log(name); // it outpus the correct value
console.log(country); // it outpus the correct value
return this.http.post('http://178.62.58.150:5000/api/cosmo/',body)
.map(res => {
res.text();
console.log(res.text());
})
.do(data => {
this.data = data;
// console.log(this.data);
})
}
Es scheint, dass es nicht um den Körper auf die POST-Anfrage sendet.
diese Ausgabe der richtige Wert des Körpers
console.log(name);
console.log(country);
Aber
console.log(res.text());
Es gibt mir ein DB Validierung Fehler, der besagt, dass der Körper und Land benötigt werden .. .
Wie sende ich den Körper richtig?
P.S. : Ich habe das mit POSTMAN getestet und es funktioniert!
hinzugefügt Das ist nicht das Problem –