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

204
Vistas
Angular: update data in InMemoryDBService

I want to update data in InMemoryDBService but it doesn't work. Propably it's a problem with client.id. I think that because in client.service.ts i tryed display in console.log user.id (like you can see in my code) but I have undefined. But client.name display correctlly text. So i made hello object with id (look at my code) but it doesn't work too. I don't have any error. This code doesn't change deta of clients and I don't have idea why. So look at my code: clients-data.service

createDb(){
    const clients = [
      {
        id: 1,
        name: 'Jan Kowalski',
        city: 'Lublin',
        streetNumber: 4,
        flatNumber: 12
      },
      {
        id: 2,
        name: 'Jan Nowak',
        city: 'Lublin',
        streetNumber: 4,
        flatNumber: 12
      },
      {
        id: 3,
        name: 'Marian Stefański',
        city: 'Lublin',
        streetNumber: 4,
        flatNumber: 12
      },
    ];
    return { clients };
  }

  genId(clients: Client[]): number {
    return clients.length > 0 ? Math.max(...clients.map(client => client.id)) + 1 : 11;
  }

client.service.ts

  private clientsURL = 'api/clients';
    updateClient(client: Client): Observable<any> {
      const hello = {id: 2, name: 'Hello World', city: 'Test', streetNumber: 'Test', flatNumber: 3};
    return this.http.put(this.clientsURL, client, this.httpOptions).pipe(
      tap(_ => console.log(`updated hero id=${client.id}`)),
      catchError(this.handleError<any>('updateHero'))
    );
  }

client-details.components.ts

  update(): void {
    if(this.client){
      this.clientService.updateClient(this.updateClientForm.value as Client)
        .subscribe(() => this.goBack());
    }
  }

Where I make a mistake?

about 4 years ago · Juan Pablo Isaza
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