Ich frage mich, wie man eine HTTP-Post-Anfrage ohne Body (speziell in Angular) sendet. Hier ist was ich jetzt mache, aber ich bekomme den Fehler Expected 2-3 arguments, but got 1)
.
Ich weiß, das zweite Argument ist für den Körper, aber ich sende das nicht an den Server (ja, ich verstehe, dass ein POST - Aufruf den Status eines Systems ändert und in THIS Frage).
postRequest(id) {
this.http.post('/api?data=' + id).map(
(response) => {
return response;
}
)
}
Sieht so aus, als wäre dies die passende Antwort:
postRequest(id) {
this.http.post('/api?data=' + id, null).map(
(response) => {
return response;
}
)
}
Wenn Null nicht funktioniert (4XX-Fehler-Clientseite), versuchen Sie es mit {} JSON
postRequest(id)
{
this.http.post('/api?data=' + id, {}).map((response) => {return response;})
}