I need Iframe URL to be changed several times a week, buy w/o changing the code. This is what my friend helped me with, but it still doesn't work. Please advise us. Thanks!
<iframe id="magicIframe" src="">
</iframe><script>
const spreadsheetId = '1pekI9iqMiVkVkRAqajMjmoTfKFsfK1LNTZGcS6NYjRk';
var iframeUrl = '';
function sheet() {
fetch(`https://docs.google.com/spreadsheets/d/${spreadsheetId}/gviz/tq?tqx=out:json`)
.then(res => res.text())
.then(text => {
const json = JSON.parse(text.substr(47).slice(0, -2));
iframeUrl = json.table.rows[0].c[0].v;
});
document.getElementById('magicIframe').src = iframeUrl;
};
window.onload = function(e) {
setTimeout(() => {
sheet();
}, "2000")
};
</script>