How can I log a value of a variable using `console.log()` or something like this?

Hi guys, I’m trying to log a variable on my Discourse app in a development environment. See this code snippet for reference:

postStream.get("posts").forEach((post) => {
        // I want to log the `post` variable
        console.log(post);
        if (!post.read && postNumbers.includes(post.post_number)) {
          post.set("read", true);
          this.appEvents.trigger("post-stream:refresh", { id: post.get("id") });
        }
      });

I’m still not very good at javascript, but

window.console.log("post",post)

Is how I do it.

Hi, thank you for replying although my issue is resolved. What happened is my log is not showing after page refresh, the logs are showing after half a minute or so, then continue to log in at intervals.

I suspect that’s because that code isn’t getting triggered?

2 Likes