Skip to content

fetch-API-II #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions JavaScript/Advance/Web API/fetch API-part2/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fetch API- Part-II</title>
</head>

<body>
<h1>Fetch API Part 2 from url</h1>
<h2>Example</h2>
<button onclick="DisplayOne()">Click</button>
<p id="textOne"></p>
<script src="script.js"></script>
</body>

</html>
11 changes: 11 additions & 0 deletions JavaScript/Advance/Web API/fetch API-part2/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Fetch API Part 2, Fetching From URL
let textOne = document.getElementById('textOne');

function DisplayOne() {
fetch('https://jsonplaceholder.typicode.com/todos/1')
.then(response => {
let resp = response;
textOne.innerHTML = resp;
console.log(textOne);
});
}