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

Ajax fetch and fetchJson method doesn't use params property #2363

Open
Velorexe opened this issue Sep 10, 2024 · 0 comments
Open

Ajax fetch and fetchJson method doesn't use params property #2363

Velorexe opened this issue Sep 10, 2024 · 0 comments

Comments

@Velorexe
Copy link

Expected behavior

Using the exported fetch and fetchJson methods with a param property in the init object should result in the passed parameters to show up as query parameters in the URL.

const resp = await ajax.fetch('/example/', { params: { query: 'param' } } );

Actual Behavior

The example above results in a request made to /example without any query parameters.

The fetch and fetchJson method exported from the Ajax method doesn't use the params property that's passed through the init parameter. The property is set to the Request object that's created, but the native fetch method in the browser doesn't use the property (neither is it in the documentation for a Request object).

Here's how it's currently implemented in the Ajax class.

  async fetch(info, init, parseErrorResponse = false) {
    const request = /** @type {CacheRequest} */ (new Request(info, { ...init }));
    request.cacheOptions = init?.cacheOptions;
    request.params = init?.params;

In the cacheManager class there's mention of a stringifySearchParams method, but it isn't called when a request is made or intercepted.

Additional context

Latest version.

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

No branches or pull requests

1 participant