I have a user form. I need user details sent to back-end. So I tried as shown below:
this.http.post("http://localhost/angular5/user-add.php", this.myform.value).subscribe(
data => {
console.log(res)
}
)
My back-end is PHP and set CORS as shown below:
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Credentials: true");
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
header('Access-Control-Max-Age: 1000');
header('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token , Authorization')
If I run this code, I am getting the below error:
ERROR Object { headers: Object, status: 200, statusText: "OK", url: "http://localhost/angular5/user-add.…", ok: false, name: "HttpErrorResponse", message: "Http failure during parsing for htt…", error: Object } core.js:1665:5
Any help is greatly appreciated. Thanks in advance.