Open akg314 opened 6 years ago
If you're having trouble setting up a proxy server because the firebase API doesn't work, here's another solution (you need chrome to make this work).
app.getForecast
app.getForecast = function(key, label) { var cityToLatLon = { 'austin': '30.3079823,-97.8938293', 'boston': '42.313479,-71.1273685', 'chicago': '41.8339032,-87.8725822', 'bangalore': '12.9539598,77.4905096', 'buenosaires': '-34.6158036,-58.5035321', 'capetown': '-33.9137107,18.0942365', 'london': '51.5285578,-0.2420244', 'mcmurdo': '-77.8401137,166.6441437', 'newyork': '40.7128,-74.0059', 'portland': '45.5425909,-122.7948484', 'sanfrancisco': '37.7578149,-122.5078116', 'seattle': '47.6149938,-122.4763319', 'sydney': '-33.7966053,150.6415579', 'tokyo': '35.6732615,139.5699601' }; var cityCoords = cityToLatLon[key]; var url = 'https://api.forecast.io/forecast/INSERT_YOUR_API_KEY_HERE/' + cityCoords; // Make the XHR to get the data, then update the card var request = new XMLHttpRequest(); request.onreadystatechange = function() { if (request.readyState === XMLHttpRequest.DONE) { if (request.status === 200) { var response = JSON.parse(request.response); response.key = key; response.label = label; app.updateForecastCard(response); } } }; request.open('GET', url); request.send(); };
If you're having trouble setting up a proxy server because the firebase API doesn't work, here's another solution (you need chrome to make this work).
app.getForecast
function in your app.js file as follows, inserting your API key from step 2: