👩‍💻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:

...

/* Parse echo3D database */

// Iterage over all database entries
var entries = []
for (let entry of Object.values(global.echoDB.db)) {
  // Parse entry
  var srcFile = "https://api.echo3D.com/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
    ...
    
  }
  
  ...

Last updated