DEV Community

Cover image for Why You Should Be Using TransferState (& Scully) to Cache Your API Calls in Angular

Why You Should Be Using TransferState (& Scully) to Cache Your API Calls in Angular

Jennifer Wadella on May 22, 2020

Caching API calls that return largely static data and be a great way to improve application performance AND save $$$ by limiting server requests. ...
Collapse
 
hussainb profile image
Hussain

Jennifer, After adding the useScullyTransferState as per your article, it does not generate any data.json for the routes. is there anything more to be done apart from using useScullyTransferState?
thanks!

Collapse
 
sumitdhameja profile image
Sumeet Dhameja

Thanks for this post Jennifer. When building, I am not seeing any data.json created for that route when running "npm run scully" Is there any config that needs to be enabled?

Collapse
 
hussainb profile image
Hussain

Hi Sumeet, I followed the steps mentioned in this article and the data.json did not get generated for me too.. were you able to make this work for you?

Collapse
 
sumitdhameja profile image
Sumeet Dhameja • Edited

Hi Hussain,
It was long time ago, but I think I had a token interceptor where i was intercepting request and adding Auth token in the header and that was causing the issue for me. When building I used "isScullyRunning" to check and skip it by calling "next"

if (isScullyRunning()) {
      return next.handle(request);
    }
Enter fullscreen mode Exit fullscreen mode

Hope it helps!

Collapse
 
ninjamonz profile image
ninjamonz

I guess 'useScullyTransferState' not yet documented on the docs. Happy to know that from here. Thanks.

Collapse
 
likeomgitsfeday profile image
Jennifer Wadella Bitovi

Yep! That's why I wrote this post! I know the Scully team is working really hard - writing documentation is tough!

Collapse
 
jwp profile image
JWP

Wow, thanks Jennifer...