Open weather api help

Open weather api help
0.0 0

#1

Hey folks. I did the weather app using the FCC weather api. However I’m trying to build my actual portfolio now. So I want to use open weather’s api. For some reason I just can’t get it to work.

https://jordijewell.co.uk/weather

Can anyone point me in the right direction?


#2

I visit your link and request to detect my coordinate appear but nothing happen afterward.

Maybe you should check how you make use of the coordinate you get


#3

You are missing an “=” in the following line. Hint: It is one of the query parameters.

 $.getJSON("https://api.openweathermap.org/data/2.5/weather?lat=" + position.coords.latitude + "&lon" + position.coords.longitude + "&APPID=4889d7d4321e890d61cd3f4c2683c52e"

#4

I can’t believe I missed that :’(

Thanks

EDIT:

I’ve edited the code:

function showPosition(position) {
    $.getJSON("https://api.openweathermap.org/data/2.5/weather?lat=" + position.coords.latitude + "&lon=" + position.coords.longitude + "&APPID=[API_KEY]",
        function (forecast) {
            $("#location").append(forecast.coord);
        console.log(forecast);
        }
             );
}


function getLocation() {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showPosition);
    } else {
        document.getElementById("location").innerHTML("Geolocation is not supported by this browser.");
    }
}

I get the data into my console, but nothing comes through into the div. doesn’t matter if I use .html or .append


#5

can you explain how to find that code ?

i tried using inspect element but only find the html code


#6