{solved}getJSON Weather API only showing address, not data

I have been stuck for months, trying different things. I cannot any data to show in my app. the console will show the web address and if I type in the web address I get the data I want but I cant get it to work in the app.

here is my code:

if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var long = position.coords.longitude;
var lat = position.coords.latitude;
//weather data api call
var myApi = “http://api.openweathermap.org/data/2.5/weather?lat="+lat+"&lon="+long+"&appid=875f74357e28cb5429508ac1e4b86c1c”;

 alert("Alert: "+myApi+" Loc: "+lat+long);   
 // getJSON request is not working, it wont pull back the data in weatherData like it should on a console log


and here is what the console logs:

and when you type that into a browser you get:

“coord”: {
“lon”: -94.52,
“lat”: 38.96
“weather”: [
“id”: 800,
“main”: “Clear”,
“description”: “clear sky”,
“icon”: “01d”
“base”: “stations”,
“main”: {
“temp”: 301.59,
“pressure”: 1016,
“humidity”: 48,
“temp_min”: 301.15,
“temp_max”: 302.15
“visibility”: 16093,
“wind”: {
“speed”: 4.6,
“deg”: 20,
“gust”: 7.2
“clouds”: {
“all”: 1
“dt”: 1501275300,
“sys”: {
“type”: 1,
“id”: 1668,
“message”: 0.0099,
“country”: “US”,
“sunrise”: 1501240586,
“sunset”: 1501291927
“id”: 4405188,
“name”: “Raytown”,
“cod”: 200

what am I missing?

You have just made my weekend! Thank you!
I did read that in the directions but I couldnt understand what it was referring to. Im still very new. Thanks for answering that for me.

1 Like