简体   繁体   中英

How to display console.log in HTML

How can I display console.log in html?
I tried many things but can't get it.
I want this out.guild.members.length to display in html. Someone can help me?

Thanks!

let url = 'MyURL';

fetch(url)
// Send an HTTP request to the API using fetch.
.then(res => res.json())
// Parse the data as JSON.
.then((out) => {
  console.log(out.guild.members.length);
  // Retrieve the member count.
 
})
.catch(err => { throw err });

i'm not quite getting your question but if you want to display out.guild.members.length in some div in HTML you can add a div inside your HTML.

HTML:

<div id="log"></div>

JS:

document.getElementById("log").innerHTML=out.guild.members.length;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM