πŸ‘©β€πŸ’» 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
1
...
2
​
3
/* Parse echo3D database */
4
var entries = []
5
for (let entry of db) { // Iterage over all database entries
6
// Parse entry
7
var srcFile = "https://console.echo3D.co/query?key=" + apiKey + "&file=";
8
var typeFile = entry['hologram'].filename.toLowerCase().split('.').pop();
9
switch (entry['hologram'].type) {
10
case 'VIDEO_HOLOGRAM':
11
case 'IMAGE_HOLOGRAM':
12
srcFile += entry['hologram'].storageID;
13
break;
14
case 'MODEL_HOLOGRAM':
15
switch (typeFile) {
16
case 'glb':
17
srcFile += entry['hologram'].storageID;
18
break;
19
case 'gltf':
20
case 'obj':
21
case 'fbx':
22
srcFile += entry['additionalData'].glbHologramStorageID;
23
break;
24
}
25
break;
26
}
27
28
// Parse additional data
29
var x = (entry['additionalData'].x) ?
30
parseFloat(entry['additionalData'].x) : 0;
31
32
// Do something with the entry
33
...
34
35
}
36
37
...
Copied!
Last modified 19d ago
Copy link