first time dealing with json, so not really sure.. when a user online the api returns with
user example
live true
viewers 22
passwordProtected false
banned false
but when im offline "viewers" gets removed. so data.viewers comes back as undefined, how can i change it to e.g offline?
script:
<script>
$.getJSON('https://example.com/api/example', function(data) {
var text = `${data.viewers}`
$(".mypanel").html(text);
});
</script>