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 filter to autosuggest fetch config #3382

Merged
merged 8 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use an existent header
  • Loading branch information
felipeelia committed Apr 4, 2023
commit efa430d2b83a9bc6b6118806c6a64b7e060de679
2 changes: 1 addition & 1 deletion tests/cypress/integration/features/autosuggest.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('Autosuggest Feature', () => {
cy.intercept({
url: /(_search|autosuggest)$/,
headers: {
'X-Custom-Autosuggest-Header': 'MyAutosuggest',
'X-ElasticPress-Request-ID': 'CustomRequestId123',
},
}).as('apiRequest');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
function() {
wp_add_inline_script(
'elasticpress-autosuggest',
"const epAutosuggestFetchOptions = ({ fetchOptions }) => {
fetchOptions.headers = {
'X-Custom-Autosuggest-Header': 'MyAutosuggest',
};
return fetchOptions;
"const epAutosuggestFetchOptions = (fetchOptions) => {
fetchOptions.headers['X-ElasticPress-Request-ID'] = 'CustomRequestId123';
return fetchOptions;
};
wp.hooks.addFilter( 'ep.Autosuggest.fetchOptions', 'ep/epAutosuggestFetchOptions', () => epAutosuggestFetchOptions );",
wp.hooks.addFilter('ep.Autosuggest.fetchOptions', 'myTheme/epAutosuggestFetchOptions', epAutosuggestFetchOptions);",
'before'
);
},
Expand Down