I'm consuming a JSON API with JavaScript and adding that content in HTML with append but when you go to another page and click Back in the browser the content is reloaded so I want to know a way to avoid this, this is the JavaScript code I'm Using.
var request = new XMLHttpRequest();
request.open('GET', 'https://localhost:3000/api', true);
request.onload = function () {
var data = JSON.parse(this.response);
if (request.status >= 200 && request.status < 400) {
data.forEach(v => {
const card = '<span><div class="card">v.content</div></span>';
$("#data").append(card);
});
}else{
console.log('Error al cargar el contenido');
}
}
request.send();
thanks for your help