Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

94
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda