Response:

Code:

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 = () => {
	fetch('example.json', { mode: 'no-cors' })
	.then(response => response.json())
	.then(promise => example.message({ msg:JSON.stringify(promise), log:promise }))
	.catch(error => console.log('Error:', error));
};

example.init = () => {
	example.process();
};

document.addEventListener('DOMContentLoaded',example.init,false);