HI all, Just starting to play around with the SDK’...
# ask-questions
b
HI all, Just starting to play around with the SDK’s. They are pretty easy to get up and running, but none of the examples are for server side features. Are they any example implementations against things like an node or expressJS server that shows best practices for refreshing the features list?
f
Hi Joshua
Let me get you some example code
b
I wouldn’t want to hit your API on every api hit to my page. But I also want to refresh my features every X minutes. I’m googling around and new to node & express, and don’t know the best practices for having a background thread call
setFeatures
f
the caching can be done any way you like, here is one that looks like it will work: https://dev.to/franciscomendes10866/simple-in-memory-cache-in-node-js-gl4
b
I ended up going with a node-cron approach. snippet shared
Untitled.txt
maybe it is useful for someone else.
f
nice, do you mind if I use that... great 🙂
b
You fire that function at boot, and it goes and does its thing.
f
on line 9 it seems to do the fetch regardless, no?
b
I don’t want the app to start without fetching the features first. That cron won’t fire for a minute.