Is there a way to update a variable in my component only after receiving a response from a POST request?
Here is the code in component.ts:
formSubmit() {
this.sent = this.submitProvider.sendByPost(this.form);
this.formSent = this.submitProvider.formSent;
}
The code in service/provider.ts looks like this:
sendByPost(form) {
return this.http.post("http://app.api.com/mail/", form, httpOptions)
.subscribe(
data => (
this.formSent = true,
), // success path
error => (console.log(error)), // error path,
() => this.formSent = true
)
}