File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <!doctype html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="UTF-8 " />
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
6+ < title > Programmer Humour</ title >
7+ < link rel ="stylesheet " href ="style.css " />
8+ < script src ="script.js " defer > </ script >
9+ </ head >
10+ < body >
11+ < img id ="comic " />
12+ </ body >
13+ </ html >
Original file line number Diff line number Diff line change 1+ function getComic ( ) {
2+ fetch ( "https://xkcd.vercel.app/?comic=latest" )
3+ . then ( ( response ) => response . json ( ) )
4+ . then ( ( data ) => {
5+ console . log ( data ) ;
6+
7+ const img = document . getElementById ( "comic" ) ;
8+ img . src = data . img ;
9+ } )
10+ . catch ( ( error ) => {
11+ console . log ( "Error:" , error ) ;
12+ } ) ;
13+ }
14+ getComic ( ) ;
Original file line number Diff line number Diff line change 1+ body {
2+ height : 100vh ;
3+ display : flex;
4+ justify-content : center;
5+ align-items : center;
6+ background-color : rgb (58 , 57 , 55 );
7+ }
You can’t perform that action at this time.
0 commit comments