Fetch -- 获取

BrE /fetʃ/ ; AmE /fɛtʃ/

  1. vt. 接来;到达;取来;吸引
  2. vi. 取物;卖得;拿
  3. n. 取得;诡计

# 栗子

一、 Fetch API

Fetch provides a generic definition of Request and Response objects (and other things involved with network requests). This will allow them to be used wherever they are needed in the future, whether it’s for service workers, Cache API, and other similar things that handle or modify requests and responses, or any kind of use case that might require you to generate your own responses programmatically(that is, the use of computer program or personal programming instructions). Fetch 提供了对 RequestResponse (以及其他与网络请求有关的)对象的通用定义。使之今后可以被使用到更多地应用场景中:无论是 service worker、Cache API、又或者是其他处理请求和响应的方式,甚至是任何一种需要你自己在程序中生成响应的方式。

fetch是一种HTTP数据请求的方式,是XMLHttpRequest的一种替代方案。fetch不是ajax的进一步封装,而是原生js,就这一点,未来一定能有很好的发展。只不过目前fetch还没有被广泛地应用,使用上面相比已发展许久的ajax各个工具,还有待改进。

二、指令周期

CPU 执行一条指令的周期叫做指令周期(instruction cycle),指令周期可以划分为 fetch、decode、和 execute 三个部分,所以也叫 fetch-decode-execute cycle。通常我们还会把存储归于其中,入下图为一个指令周期:

fetch

fetch在这里是CPU的一个工作状态,当正在获取指令内容的时候由它来表示。

三、获取数据

This API request fetches your blog posts. Your account comes with one example post which you’ll see in the response. 这个 API 请求会获取你的博客文章列表。你将会在请求的响应中看到你的账户的一篇示例博文。

这里就不是原生js的Fetch了,就是指请求接口时获取数据。

# 最后

这个单词没什么难点,就是要记住,前端的同学应该比较熟悉了。大部分时间就是用来表达想从某个接口获取数据。

关注公众号【程序员英语词汇】获取最新内容
程序员英语词汇
Copyright © 2020 Ted Yuen