mock service worker not working with axios post and payload

Viewed 533

I'm running into a weird problem. Mock Service Worker is not intercepting axios.post with a payload. Without the payload it works. For exmaple:

This works:

await axios.post(`${BASE_URL}/test.json`);

This does not work:

await axios.post(`${BASE_URL}/test.json`, { id: 1 });

by just adding { id: 1 } MSW does not intercepts the call.

Any idea?

2 Answers

There's been a known issue with intercepting POST requests. It should be fixed in the latest version of MSW (0.43.1 by the moment of answering). Please update the package and follow the release notes in case there are any breaking changes you should be aware of.

I also had this issue. (prev version 0.41.0) Please update latest version... ssibure....

Related