File tree Expand file tree Collapse file tree 3 files changed +30
-0
lines changed
JavaScript/Advance/Web API/fetch API-part2 Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < html lang ="en ">
3+
4+ < head >
5+ < meta charset ="UTF-8 ">
6+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge ">
7+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
8+ < title > Fetch API- Part-II</ title >
9+ </ head >
10+
11+ < body >
12+ < h1 > Fetch API Part 2 from url</ h1 >
13+ < h2 > Example</ h2 >
14+ < button onclick ="DisplayOne() "> Click</ button >
15+ < p id ="textOne "> </ p >
16+ < script src ="script.js "> </ script >
17+ </ body >
18+
19+ </ html >
Original file line number Diff line number Diff line change 1+ // Fetch API Part 2, Fetching From URL
2+ let textOne = document . getElementById ( 'textOne' ) ;
3+
4+ function DisplayOne ( ) {
5+ fetch ( 'https://jsonplaceholder.typicode.com/todos/1' )
6+ . then ( response => {
7+ let resp = response ;
8+ textOne . innerHTML = resp ;
9+ console . log ( textOne ) ;
10+ } ) ;
11+ }
You can’t perform that action at this time.
0 commit comments