[英]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. Mock Service Worker
没有拦截带有有效负载的axios.post
。 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.只需添加
{ id: 1 }
MSW 不会拦截呼叫。
Any idea?任何想法?
There's been a known issue with intercepting POST requests.拦截 POST 请求存在一个已知问题。 It should be fixed in the latest version of MSW (
0.43.1
by the moment of answering).它应该在最新版本的 MSW 中修复(回答时为
0.43.1
)。 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....
(prev version 0.41.0)请更新最新版本... ssibure....
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.