Ahmed Zougari• 270
@zougari47
Posted
Hi there👋,
I have faced this problem before, you need to clear cache every time you use fetch API
This is the solution for your code
function getAdvice(){
fetch('https://api.adviceslip.com/advice', {
cache: 'no-cache'
}).then(response =>{
return response.json();
}).then(adviceData =>{
const adviceObj = adviceData.slip;
resDiv.innerHTML = `<p>${adviceObj.advice}</p>`;
resTitle.innerHTML = `ADVICE #${adviceObj.id}`;
console.log(adviceObj.advice);
}).catch(error =>{
console.log(error);
})
}
``
Marked as helpful
0
Ciceron• 940
@MarcusTuliusCiceron
Posted
@zougari47 :D yeah that works, thank you very much for info
0