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

315
Views
Angular 7+ : how can I implement a refresh from api endpoint silently?

I'm looking for some opinions to implement a 'silent' fetch from a given data endpoint.

Currently I have an implementation to fetch data on component init as you would expect

//apiService.ts
getData(params): Promise < Member[] > {
  return this.httpService.doRequest(`${this.baseUrl()}/member`, 'get', convertToQueryParams(params), null);
}


//component.ts
this.apiService
  .getData(params)
  .then((response: any) => {
    const responseData: Member[] = response.data
    this.data = responseData.map(member => new Display(member))
  })
  .catch(e => console.log('error occured while fetching table data. Try again: ', e))

After this I would like to implement a silent refresh on the same getData endpoint which fetches the data every 5 minutes and silently paints the page with new data without user realizing the data was updated. This also means not showing any sort of loading or refresh behavior on the page for this silent fetch.

My organization currently uses angular 7 but we plan to upgrade to angular 12 this year. Any ideas or suggestions would be appreciated.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Since you are working in Angular, you can always use observables. I see you are using a promise but retuning an observable is a quick fix. You can use the timer function which will do exactly what you want: https://www.learnrxjs.io/learn-rxjs/operators/creation/timer

Another option is to use setInterval and save its reference so you can cancel it when a component is destroyed. https://developer.mozilla.org/en-US/docs/Web/API/setInterval

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!