πŸ‘©β€πŸ’» Edit Code
Learn how to edit code and parse data in your React Native project.
Now that you are able to successfully fetch data into React Native, it's time to parse it 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
​
5
// Iterage over all database entries
6
var entries = []
7
for (let entry of Object.values(global.echoDB.db)) {
8
// Parse entry
9
var srcFile = "https://api.echo3D.co/query?key=" + apiKey + "&file=";
10
var typeFile = entry['hologram'].filename.toLowerCase().split('.').pop();
11
switch (entry['hologram'].type) {
12
case 'VIDEO_HOLOGRAM':
13
case 'IMAGE_HOLOGRAM':
14
srcFile += entry['hologram'].storageID;
15
break;
16
case 'MODEL_HOLOGRAM':
17
switch (typeFile) {
18
case 'glb':
19
srcFile += entry['hologram'].storageID;
20
break;
21
case 'gltf':
22
case 'obj':
23
case 'fbx':
24
srcFile += entry['additionalData'].glbHologramStorageID;
25
break;
26
}
27
break;
28
}
29
30
// Parse additional data
31
var x = (entry['additionalData'].x) ?
32
parseFloat(entry['additionalData'].x) : 0;
33
34
// Do something with the entry
35
...
36
37
}
38
39
...
Copied!
Last modified 18d ago
Copy link