how to ignore queryString (params) when doing a mock
See original GitHub issuetried:
mock.onGet( apiPath('/Facility') ).reply(config=>{
console.log(config);
return [
200,newItem(1)
]
})
mock.onGet( apiPath('/Facility'),{ params: { facilityId: /\d+/ } } ).reply(config=>{
console.log(config);
return [
200,newItem(1)
]
})
apiPath is just a function that returns a full apiUrl, whether it be dev, staging or production. any help would be appreciated
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:5
Top Results From Across the Web
How to tell wiremock to ignore query strings parameters in ...
What I'm facing is that any query parameter appended in the request URL breaks my mock, so a call to http://mockurl/myurl?query=string gives me...
Read more >How can I delete a query string parameter in JavaScript?
This doesn't work if you have two query strings and remove the first. The passed in url becomes invalid because the ? is...
Read more >Ignoring Query String Parameters - SmartBear Support
To do this, enable the Ignore dynamic URL parameters property of your project and specify the list of parameters to ignore. For example,...
Read more >Query parameters - Recipes - Mock Service Worker Docs
In order to access a query parameter of the intercepted request, use the searchParams property on the req.url instance.
Read more >Best Practice: Caching Everything While Ignoring Query Strings
Enterprise customers can cache any type of static content, like HTML files, and ignore query strings in the resource URL by using Custom......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I’m trying to mock a GET request without specifying the params that it should match on.
According to the example docs:
You should be able to mock just a URL without specifying params and this should match on all GET requests with whatever query params they send in. This however is not the case. If a request sends in query params then this mock doesn’t match. Is this the same problem you’re having @r3wt ?
The solution for this problem is to use regex @r3wt in your case that would look like this:
This would match request to
/Facilityand also/Facility?x=1&y=2etc