DEV Community

Jayavignesh R
Jayavignesh R

Posted on

How to Achieve Auto Complete faster in Angular via API

Hi, I am currently working on a side project, which uses Third Party API Data search with Autocomplete.

I have written the code in way that
(Text Input) - > Make REST call to MY Server with query Param -> Then My Spring application makes a Rest Template call with API Key and other param to Third Party application. -> On receiving the large JSON it will filter and then return the Array of Suggestion to Angular application.

But the autocomplete is not instantaneous and responsive. I cant call the third-party directly from UI.
Any suggestions on it.

Top comments (2)

Collapse
 
briancodes profile image
Brian

There's no way around calling your API first if the 3rd party API keys are secret. To speed things up you could:

  • cache your API responses server side e.g. redis
  • add caching client side with a service worker
  • use an Rxjs throttle and switchMap on the UI's requests
Collapse
 
jai555 profile image
Jayavignesh R

Thanks for the suggestion. I will give a try to implement this.