justin zhao
288 posts

justin zhao
@justinz_Chiu
love coffee and cat,job is coding,frontEnd engineer in china,mamba mentality
china/foshan Katılım Mart 2023
88 Takip Edilen24 Takipçiler
justin zhao retweetledi

当你还在用原生 fetch 的时候,可以考虑使用 ky:
github.com/sindresorhus/ky
可以对比一下左右两边的代码
API 简单 / 非200状态码直接处理为错误/ 更好的TS 支持 / 压缩以后特别小
还可以选用 ofetch github.com/unjs/ofetch
现在我两个都在使用。
什么?你说 Aixos ?基于 XMLHttpRequest,还比较大,我已经慢慢放弃它了。
慢慢发现 Reddit 讨论技术问题有时候特别棒,SEO 现在很靠前,又能学到很多知识,有些回答也特别搞笑。
比如这个使用 fetch 替代 Axios 的理由:
reddit.com/r/webdev/comme…

Cory House@housecor
Using fetch? Consider Ky. Benefits: - Simpler API - Requires about half the code - Treats non-2xx status codes as errors - Includes timeout support - Retries failed requests - Better TS support. json() resolves to unknown Here's fetch vs Ky - literally half the code. 🔥
中文




















