Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

API Fetch not pulling data

all this is my first attempt at trying to write my first API fetch and I keep getting the following error Uncaught (in promise) ReferenceError response is not defined at getISS (index.html:19) These are the 2 lines that seem to be causing the problem:

const data = await response.json();
getISS();

Not entirely sure how to fix this issue.

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    </head>
    <title> API Test </title>
    <body>
    
        <h1>Where is the ISS? </h1>
        
        <p>Latitude: <span id="lat"></span><br />
        Longitude: <span id="lon"></span>

        <script>
        const iss_url = 'https://api.wheretheiss.at/v1/satellites/25544';
        async function getISS() {
        const respone = await fetch(iss_url);
        **const data = await response.json();**
        const { latitude, longitude } = data;
            
        document.getElementById('lat').textContent = latitude;
        document.getElementById('lon').textContent = longitude;
        }
        
        **getISS();**
        
        </script>
    </body>
</html>

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Looks like you have a typo at const respone = await fetch(iss_url); should be response not respone.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading