[英]Angular http POST unable to send post parameters
這是我用來撥打電話的內容:
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json'
})
};
this.http.post("https://fakedomain.com/info.php", { "uuid": this.device.uuid, "funcion": "saveFormulario"}, httpOptions).subscribe(response => {
this.datos = response;
});
這就是服務器獲取的所有信息:
POST /info.php HTTP/1.0
HTTP headers:
Host: fakedomain.com
X-Forwarded-Proto: https
Accept-Encoding: gzip, deflate, br
Connection: close
Pragma: no-cache
Cache-Control: no-cache
Accept: application/json, text/plain, */*
Origin: http://192.168.0.118:8100
User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1
Referer: http://192.168.0.118:8100/
Accept-Language: en-US,en;q=0.9,es;q=0.8
Request POST:
Request GET:
Request body:
{"uuid":"testuuid","funcion":"saveFormulario"}
因此,信息正在發送,但在$ _POST方面卻什么也沒有。
我究竟做錯了什么?
這是解決此問題的原因:
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/x-www-form-urlencoded'
})
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.