简体   繁体   中英

mock service worker not working with axios post and payload

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?

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....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM