I'm sorry if the title is not very clear. In my Angular project, I have come across two different put requests:
public Save() {
const types: string[] = this.getTypes.getCurrentTypes();
this.userTypeService
.updateTypes(this.userID, groups)
.subscribe(() => {
showToast("success", "User types Updated.");
});
}
where updateTypes is a function that sends a simple httpPut request.
What sets this apart from another similar function that uses
.subscribe(
showToast("success", "user types updated");
)
In essence, what does the () => do in the subscribe function? Is there also a proper way to handle errors with this approach?
UPDATE: I've found the solution that works for me by using this code:
public Save() {
const types: string[] = this.getTypes.getCurrentTypes();
this.userTypeService
.updateTypes(this.userID, groups)
.subscribe(
result => showToast("success", "User types Updated."),
error => showToast("error", "Error")
);
}