代码示例:(标识:js_api_fetch_easy)
<!DOCTYPE html>
<html>
<body>
<p id="demo">获取文件以更改此文本。</p>

<script>
getText("/static/demo/txt/fetch_info.txt");

async function getText(file) {
  let myObject = await fetch(file);
  let myText = await myObject.text();
  document.getElementById("demo").innerHTML = myText;
}
</script>

</body>
</html>
运行结果: