const example = { scope: null }; example.message = (args) => { if(args.log) console.log(args.log); if(args.msg) document.getElementById('viewport').innerHTML = args.msg; }; example.process = () => { (async function read(){ const file = await fetch('example.json'); let promise = await file.json(); example.message({ msg:JSON.stringify(promise), log:promise }) })(); }; example.init = () => { example.process(); }; document.addEventListener('DOMContentLoaded',example.init,false);