Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Allow providing your own implementation of fetch #160

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

opepin
Copy link

@opepin opepin commented Jun 8, 2024

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

@opepin opepin requested a review from a team as a code owner June 8, 2024 18:35
Copy link

salesforce-cla bot commented Jun 8, 2024

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.

@joeluong-sfcc
Copy link
Contributor

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?

@opepin
Copy link
Author

opepin commented Jul 3, 2024

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) => {
let [resource, config ] = args;
console.log('request interceptor before')
const response = await originalFetch(resource, config);
console.log('request interceptor after')
return response;
};

before calling the api

@opepin opepin changed the title Issue 159 [Feature] Allow providing your own implementation of fetch Aug 23, 2024
@opepin
Copy link
Author

opepin commented Aug 23, 2024

fixes #159

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants