首页 > 解决方案 > React Native 最终无法识别

问题描述

finally 关键字在经典的 es6 helloworld 获取示例中未定义。

let isLoading = true;

fetch("https://jsfiddle.net").then(function(response) {
    var contentType = response.headers.get("content-type");
    if(contentType && contentType.includes("application/json")) {
      return response.json();
    }
    throw new TypeError("Oops, we haven't got JSON!");
  })
  .then(function(json) { /* process your JSON further */ })
  .catch(function(error) { console.error(error); /* this line can also throw, e.g. when console = {} */ })
  .finally(function() { isLoading = false; console.log("done")});

标签: javascriptreactjstypescriptreact-native

解决方案


推荐阅读