Cache a request response
Description
Hi all, I cannot find anything in documention that suggests how to create a custom requesterFn. In can see that the method signature it expects is (resourceOptions: ResourceOptions) => RequesterType but I cannot even import those types.
What I am trying to achieve it to simply use a cache library (like https://www.npmjs.com/package/flat-cache) to check if the data has been already asked, and return it if cache hit... or ask for the data in case of cache miss.
If anyone can help would be great (if you have an example I could use even better :) )
I would like to create a custom requesterFn that cache the response.
Checklist
- [x] I have checked that this is not a duplicate issue.
- [x] I have read the documentation.
@jdalrymple I would also like to know how to implement a custom requester function. I tried to look through the docs for one because I noticed it was required but didn't find anything. Do you mind posting or linking an example of how this would be done please?
Hi @jdalrymple ,
I also tried creating a custom requesterFn to add some special headers to my calls. After struggling a lot (due to my non-existing typescript skills) I got to create the function but could not handle the response correctly.
In the end I could not wrap my head around it and just copied the defaultRequestHandler implementation as it is not exported. Of course this is not very nice, but hey, it works!!! [insert bittersweet smiley here]
So, my questions are:
- Is there any documentation already available?
- Are you willing to export the
defaultRequestHandler? I saw this was also a topic in this issue https://github.com/jdalrymple/gitbeaker/issues/3403
thanks a lot !
I was in the process of exporting it nicely, but ran into a whole bunch of other problems which has delayed things considerably. The plan is to do this correctly, I'm sorry it was such a pain to implement :(.
yes, without defaultRequestHandler, it's quite hard to implement custom requesterFn