SHARE
TWEET

Untitled

a guest Jul 19th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var loadJSON = d3.json("/json/zips_us_topo.json");
  2.     var dataJSON = d3.json("/json/CustomersByZip.json",
  3.         function(d){
  4.             zipcodeData.set(d.Zipcode, d.TotalPatients,d.ColorHex);
  5.         });
  6.  
  7.     //Promise
  8.     Promise.all([loadJSON, dataJSON]).then(addZips).catch(console.log.bind(console));
  9.  
  10.     function addZips([us]) {
  11.  
  12.         var myJSON = JSON.stringify(us);
  13.         console.log(myJSON.substring(0,200)); // Returns first 200 characters of loadJSON file, so I know I can just reference it with "us".
  14.  
  15.         console.log(dataJSON); // displays "Promise {<resolved>: {...}}
  16.         console.log(loadJSON); // displays "Promise {<resolved>: Array(28355)}" so it loaded the dataJSON data but how do I reference it?
  17.  
  18.         console.log(us[0]); // displays "undefined"
  19.         console.log(us[1]); // displays "undefined"
  20.  
  21.         console.log(us[0][0]); // TypeError: Cannot read property '0' of undefined
  22.         console.log(us[1][0]); //TypeError: Cannot read property '0' of undefined
  23.  
  24.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top