👩‍💻 Edit code

Learn how to edit code and parse data in your JavaScript project.

Now that you are able to successfully fetch data into JavaScript, it's time to parse the data in your code.

You can iterate over all entries in the fetched database and parse them based on the data structures details in our API. For example:

app.js
app.js
...
/* Parse echoAR database */
var entries = []
for (let entry of db) { // Iterage over all database entries
// Parse entry
var srcFile = "https://console.echoar.xyz/query?key=" + apiKey + "&file=";
var typeFile = entry['hologram'].filename.toLowerCase().split('.').pop();
switch (entry['hologram'].type) {
case 'VIDEO_HOLOGRAM':
case 'IMAGE_HOLOGRAM':
srcFile += entry['hologram'].storageID;
break;
case 'MODEL_HOLOGRAM':
switch (typeFile) {
case 'glb':
srcFile += entry['hologram'].storageID;
break;
case 'gltf':
case 'obj':
case 'fbx':
srcFile += entry['additionalData'].glbHologramStorageID;
break;
}
break;
}
// Parse additional data
var x = (entry['additionalData'].x) ?
parseFloat(entry['additionalData'].x) : 0;
// Do something with the entry
...
}
...