[Feature] Allow providing your own implementation of fetch #160
[Feature] Allow providing your own implementation of fetch #160opepin wants to merge 3 commits intoSalesforceCommerceCloud:mainfrom
Conversation
|
Thanks for the contribution! Unfortunately we can't verify the commit author(s): Olivier Pepin <o***@m***.com>. One possible solution is to add that email to your GitHub account. Alternatively you can change your commits to another email and force push the change. After getting your commits associated with your GitHub account, sign the Salesforce Inc. Contributor License Agreement and this Pull Request will be revalidated. |
|
Hi @opepin, thanks for creating this PR. Would you be willing to provide some documentation/example on how you would pass in a custom implementation of a fetch call and adding a unit test? |
|
I don't have a unit test, but the idea would be to override the window.fetch method : const { fetch: originalFetch } = window; window.fetch = async (...args) => { before calling the api |
|
fixes #159 |
Allow providing your own implementation of fetch by delaying caching from instanciation to first call.
Fetch can now be instrumented for performance monitoring/error or data capture. https://docs.logrocket.com/docs/troubleshooting-sessions#network-requests-are-missing-or-not-being-recorded