File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed
Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -12,10 +12,24 @@ fetch('http://localhost:8001/fetch', {
1212} ) . then ( function ( data ) {
1313 // This is the JSON from our response
1414 for ( i in data [ 'headlines' ] ) {
15+ let htmlstring = `
16+ <div class="card-body">
17+ <h5 class="card-title">${ data [ 'headlines' ] [ i ] [ 0 ] } </h5>
18+ <p class="card-text">
19+ ${ data [ 'headlines' ] [ i ] [ 2 ] }
20+ </p>
21+ <a href="https://${ data [ 'headlines' ] [ i ] [ 1 ] } " class="btn btn-primary">
22+ More
23+ </a>
24+ </div>
25+ `
1526 let div = document . createElement ( 'div' )
16- div . innerText = data [ 'headlines' ] [ i ]
27+ div . innerHTML = htmlstring . trim ( )
28+ div . className = "card col-sm-3 m-2"
29+ div . style = "max-width: 15rem;"
30+
1731 document . getElementById ( "news-from-api" ) . appendChild ( div )
18- if ( i == 10 ) break
32+ if ( i == 11 ) break
1933 }
2034 console . log ( data ) ;
2135} ) . catch ( function ( err ) {
Original file line number Diff line number Diff line change @@ -170,7 +170,7 @@ <h5 class="card-title">Pymetaheuristics</h5>
170170 </ div >
171171 </ div >
172172
173- < div id ="news-from-api "> </ div >
173+ < div id ="news-from-api " class =" row d-flex justify-content-between " > </ div >
174174 </ div >
175175 < div class ="d-flex justify-content-center my-3 ">
176176 < a class ="btn btn-seconday " role ="button " href ="# ">
You can’t perform that action at this time.
0 commit comments