How is it possible to post form data to an external rest api?
At the moment i have an html form:
Ok, so it turns out i have to add .subscribe() to post for it to do something. Also if i put "user" straight into post request for some reason it sends an request with method "OPTIONS" without a body. So i have to create a queryParams string myself. If anyone can explain this or show a better way to do this i would appriciate it. Otherwise this currently works:
onSubmit = function (user) {
console.log(user);
var body = "firstname=" + user.firstname + "&lastname=" + user.lastname + "&name=" + user.name;
this.http.post("http://www.testtttt.com", body).subscribe((data) => {});
}
Edit: another and probably even a better solution is to use JSON.stringify(user) instead of body. But subscribe() is still needed tho.