Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
PromisesFetch1.html 674 B
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Example</title>
    <meta charset="utf-8">
</head>

<body>
    <script>
        
        let url = "https://jsonplaceholder.typicode.com/todos/1"; // Notice the 1 at the end
        alert(`Retrieving data from ${url} (check console for results)`);
        
        const promise = fetch(url);
        console.log(promise);
        promise.then(response => {console.log(response); return response.json()}).then(json => console.log(json));  // Process json object by displaying on the console
        console.log("***** END OF SCRIPT *****"); // Check WHERE this message appears in the console
    </script>
</body>

</html>