Hype Data Magic

Example loading data through JSON

As @h_classen mentioned. That is possible and is even easier with the auto-refresh (v1.3.3) when setting data. See the following example:
simple_fetch_example_with_hype_data_magic.hype.zip (41,6 KB)

This example is with a simple fetch that loads from resources without any preloader or error handling (easy to add, though). Nothing fancy, but it should demonstrate the case. The code snippet used is:

// element - DOMHTMLElement that triggered this function being called
// event - event that triggered this function being called
function fetch(hypeDocument, element, event) {
	// load data using fetch 
	fetch('${resourcesFolderName}/test.json')
		.then(response => response.json())
		.then(data => {
			HypeDataMagic.setData(data);
		});
}

PS: You can also directly include data (head) or use JSONP to avoid any Cross-Origin-Policies.

2 Likes