关于fetch方法

发布于 6 年前作者 ping9718787 次浏览最后编辑 6 年前来自 ask

function fetchURL(url, callback) {

  return fetch(url)

    .then(function (response) {

      console.log('5 '+response.status);

      if (response.status == 200) {

        return response.json();

      }

    }).then(function (data) {

      console.log(data);

      if (typeof callback == ‘function’) {

        callback(data);

      }

    });

}

为什么这个方法走到fetch()的时候就报错了?

0 回复
暂无回复