Skip to content

Intercept requests with query parameters #1315

Answered by kettanaito
AndrianStoikov asked this question in Q&A
Discussion options

You must be logged in to vote

Hey, @AndrianStoikov. That's a great question.

Since you're writing a server-side behavior with MSW, we disregard request query parameters during request matching. We do so because query parameters are additional information to the request but not request identifier like the request URL/path. You can still access the query parameters so they are not ignored in that manner.

Due to the constrains of your setup, I don't think it's viable to perform conditional checks for the query parameters in all handlers every time. I would recommend creating a custom request handler in your case where you'd abstract that check.

Custom request handler

function toResource(queryParams, resolver) {
  return [

Replies: 4 comments 8 replies

Comment options

You must be logged in to vote
4 replies
@AndrianStoikov
Comment options

@AndrianStoikov
Comment options

@kettanaito
Comment options

@kellyrmilligan
Comment options

Answer selected by AndrianStoikov
Comment options

You must be logged in to vote
3 replies
@kettanaito
Comment options

@holylander
Comment options

@kettanaito
Comment options

Comment options

You must be logged in to vote
1 reply
@kettanaito
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants