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

Add support for beforeSend callback #68

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

Conversation

zokioki
Copy link

@zokioki zokioki commented Dec 25, 2021

This allows ahoy to be configured with an optional beforeSend callback, allowing the user to modify a request before sending if needed. For example:

ahoy.configure({
  beforeSend: (xhr, settings) => {
    // do something with request ...
  }
});

One use case for this is to allow for the setting of custom headers on a per-request basis.

This change allows the user to specify a callback which will fire
before a request is triggered. The function will have access to
the XHR object and settings object.
This ensures the request data being passed to the beforeSend callback
is in the same format for both the ajax and XMLHttpRequest versions.
@zokioki zokioki marked this pull request as ready for review December 25, 2021 22:32
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.

1 participant