首页 > 解决方案 > 如何从字符串中打印元素?

问题描述

嘿,我有这段代码,我在其中发出获取请求,结果在控制台上被字符串化。我想取一个特定的值并将其打印在网页的某个段落上。我怎样才能做到这一点?

<script type="text/javascript">
 fetch('https://ethgasstation.info/api/ethgasAPI.json?api-key=apikey')
  .then(response => response.json())
  .then(json => console.log(JSON.stringify(json)))
</script>

标签: javascriptjson

解决方案


推荐阅读