File size: 925 Bytes
180b13e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// script.js

// This script will fetch the summarized data from the backend and populate the HTML

document.addEventListener('DOMContentLoaded', function() {
    fetchSummaries();
});

function fetchSummaries() {
    fetch('/api/summaries')
        .then(response => response.json())
        .then(data => {
            populateNewsletter(data);
        })
        .catch(error => console.error('Error:', error));
}

function populateNewsletter(summaries) {
    const newsletterSection = document.getElementById('newsletter');

    summaries.forEach(summary => {
        const article = document.createElement('article');
        const h2 = document.createElement('h2');
        const p = document.createElement('p');

        h2.textContent = summary.title;
        p.textContent = summary.content;

        article.appendChild(h2);
        article.appendChild(p);

        newsletterSection.appendChild(article);
    });
}