【问题标题】:What is the difference between `isomorphic-fetch` and `isomorphic-unfetch` npm packages`isomorphic-fetch` 和 `isomorphic-unfetch` npm 包有什么区别
【发布时间】:2020-08-12 11:30:03
【问题描述】:

我看到两者都用于 SSR。那么有什么区别呢?除了同构获取being older and slightly larger gzipped package

链接:

Isomorphic Unfetch

Isomorphic Fetch

【问题讨论】:

  • 在问题正文中包含链接或至少包含 names 很有用。我不能轻易地从标题中复制名称,以便检查它们到底是什么,因为标题是一个可点击的链接。
  • 主要区别在于它们似乎是由两个不同的人编写的
  • @VLAZ 添加了链接。
  • 这些 cmets 都没有用。

标签: node.js reactjs next.js nestjs server-side-rendering


【解决方案1】:

isomorphic-fetch 建立在 whatwg-fetch 之上,isomorphic-unfetch 建立在 unfetch 之上。他们俩正在做的是在node-fetch 和另一个客户端和服务器包之间切换。

所以他们的区别只在客户端,问题归结为:whatwg-fetchunfetch 有什么区别?

whatwg-fetch 包是用于 fetch API 的几乎完整的 polyfill,但 unfetch 在构建时将“包大小”作为第一要务(就像 Jason Miller 编写的其他包一样,例如 preact )。 unfetch 仅支持完整提取 API 的子集。但是,如果您的应用程序中只需要简单的请求,那就太好了。

新应用程序的一个好策略是首先使用unfetch,如果您需要unfetch 不支持的任何功能(例如streaming),则将其替换为whatwg-fetch

【讨论】:

    猜你喜欢
    • 2016-10-22
    • 2021-01-03
    • 2017-02-04
    • 1970-01-01
    • 1970-01-01
    • 2019-08-20
    • 1970-01-01
    • 2017-09-25
    • 2018-09-06
    相关资源
    最近更新 更多