Load External Data

Hello everyone, I followed this example:

https://digitalfuturestold.medium.com/adding-dynamic-data-from-javascript-to-hype-websites-a8a9bdb16930

and the data is easily loaded into my scene.
The problem is that if I change the data in the data.js file, I have no way to reload it to update my text fields.

I need to update, from an external source, my data because they change over time.

Can anyone help me?
Thanks in advance

Since no one is replying, maybe this template and tutorial helps…

Basically, I'm using a Multidimensional Array (similar to JSON) to keep track of all the text in the elements. So, if a different language button is clicked, the text boxes update with the appropriate text.

So, if you've mastered that concept, the next part is how you're updating the data? Are you simply manually uploading a data.js file to the server and then Hype is supposed to read from that?

If so — then the template should be very helpful. You'd just need to create the JavaScript code to read from the data.js and then populate the elements in the Hype project. That's basically what the multilingual project is doing. Even though it's small, it's kinda like a database of information.

If not — If you're trying to make your Hype project update dynamically, maybe JSON is the way to go. JavaScript can fetch JSON data. Once that data is loaded, it can be used to update elements in the Hype project.

That can be tricky though, as it involves asynchronous functions. Also, if you're working with data from an external source, you'll have to sanitize that data. There are security issues when working with external data. Even if you trust the source, what if the source is suddenly compromised? :scream_cat:

Anyway, that's just some general commentary. From the way the problem is described, that's likely how I'd solve the problem. Maybe that information is helpful, maybe it's not. :smile:

Also, you can utilize Hype Data Magic. I often used external data files in my projects, like a data.js.

I think I'm a little unclear on some aspects:

  • Are you wanting to update the data.js file based on other data? (that is, there's no Hype changes that actually need to be done, but you need some pipeline where you want to update that?)

  • Are you wanting the hype-based webpage to change its values live without a user needing to reload?

  • Or is it you're more speaking to a particular issue where you do update the data.js file, but the new values aren't actually being reflected? In this case, it may represent overzealous caching and you need a way to make sure the current data.js file is always loaded?

1 Like