使用 fetch() 返回的 Promise 对象进行数据处理和错误处理。
例如,以下代码从服务器获取 JSON 数据,并在成功时将其输出到控制台上:
fetch('https://example.com/data.json') .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error(error));
上一篇:不使用通道层或任何其他免费托管的频道
下一篇:不使用通配符的Stackdriver高级筛选查询