Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

96
Views
Efficient call of two PATCH functions in submit

I call two functions from a service in my submit function saveProfileContent() to save changed data via PATCH. This operation also works. Is it possible to make the two calls a bit more abstract, efficient and flexible? Do you have any ideas? I am curious about your contributions and ideas.

My Code:

// TS

**
   * To save entries in the ProfileContent
   */
  saveProfileContent() {
    this.submitted = true;

    // Stop here if form is invalid
    if (this.profileContentForm.invalid) {
      return { required: true };
    }

    const values = this.profileContentForm.value;
    console.log('Show values', values);
    const successText = 'Ihre Daten wurden erfolgreich gespeichert!';
    const errorText = 'Ihre Daten konnten nicht gespeichert werden!';
    this.profileContentAlertType = null;
    this.profileContentMessage = null;
    this.userAreaService.changeUserEntries(`${values.userId}`, values).subscribe(
      currentUserData => {
        console.log('You change the currentUserData', currentUserData);
        this.submitted = false;
        if (currentUserData.success) {
          this.profileContentAlertType = 'success';
          this.profileContentMessage = successText;
        } else {
          this.profileContentAlertType = 'error';
          this.profileContentMessage = errorText;
        }
      },
      error => {
        this.submitted = false;
        this.profileContentAlertType = 'error';
        this.profileContentMessage = errorText;
      });
    this.userAreaService.changeSetup(values).subscribe(
      currentMandantData => {
        console.log('You change the currentMandantData', currentMandantData);
        this.submitted = false;
        if (currentMandantData.success) {
          this.profileContentAlertType = 'success';
          this.profileContentMessage = successText;
        } else {
          this.profileContentAlertType = 'error';
          this.profileContentMessage = errorText;
        }
      },
      error => {
        this.submitted = false;
        this.profileContentAlertType = 'error';
        this.profileContentMessage = errorText;
      });
  }
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

looks good to me. although depending on constraints, it seems that there's an overlapping domains: data in user entry is most likely the same as the setup.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!