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

205
Views
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
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!