获得徽章 0
- 遇到了个问题,设置了一个过滤器继承了OncePerRequestFilter,然后在有@PreAuthorize注解的接口,就会报"用户名或密码错误",有点摸不着头脑,有没有大佬指点一下呀
44 - 我在知乎上看到这样一个。axios 封装 取消请求函数。我写的只是大概思路。 有没有 jy 看到过类似的。
```javascript
function withCancel(fetcher) {
let cancelSource = null
const CancelToken = axios.CancelToken;
cancelSource = CancelToken.source();
const getData = () => {
cancel();
fetcher();
}
const cancel = () => {
if (cancelSource) {
cancelSource.cancel()
}
}
return [getData, cancel];
}
```展开64
![[衰]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_34.cf5b4d5.png)
![[绝望的凝视]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_69.cabd864.png)
![[闭嘴]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_8.c6ea514.png)