Open weather api help

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?

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

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"

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

can you explain how to find that code ?

i tried using inspect element but only find the html code

1 Like