Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
PromisesFetch2.html 500 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}`);
        
        fetch(url) // Get data
            .then(response => response.text()) // Process response by retrieving text 
            .then(text => document.writeln(text));  // Displaying text
    </script>
</body>

</html>