Skip to content

Capturing request and reponses for Unhandled requests #1729

Answered by kettanaito
v-mwalk asked this question in Q&A
Discussion options

You must be logged in to vote

Hey, @v-mwalk. Thanks for raising this.

First things first, the onUnhandledRequest function is not intended to affect the traffic in any way. This extends to its inability to observe the actual response because it's out of its intended scope. You shouldn't be using this function for anything but to tell MSW how to react to unhandled requests: throw an error, warn you, or do nothing. Think of it as a logger customization function that lives outside of the request resolution algorithm (that's precisely what it is).

You may try using rest.all('*') for your use case but bear in mind that you don't have access to the original response instance there. You can, however, perform the request as-is…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@v-mwalk
Comment options

@kettanaito
Comment options

Answer selected by v-mwalk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants