C

msw/2/ctx-fetch

How to Use
Run this codemod on your codebase using one of the following commands

The easiest way to run this codemod without installing anything globally:

Documentation

ctx.fetch(req) is now meant to be called as fetch(bypass(req)) where bypass is a new function available in the msw library. Changes applied by this codemod:

  • ctx.fetch(req) is replaced with fetch(bypass(req)).

NOTE: The bypass call is meant to wrap the new request object available on the callback argument. This object is not being destructured in this codemod, so you will have to do it manually or run a callback-signature codemod that will do that and replace the reference for you.

Before

ts

After

ts

Ready to contribute?

Build your own codemod and share it with the community.