function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
};
const req = new Request('https://www.xkcd.com/info.0.json');
const out = await req.loadJSON();
const max = out['num'];
const number = getRandomInt(0, max);
const imgreq = new Request('http://www.xkcd.com/' + number + '/info.0.json');
const imgres = await imgreq.loadJSON();
const img1 = imgres['img'];
const imgf = new Request(img1);
const img = await imgf.loadImage();
const ui = new UITable();
ui.removeAllRows();
let rw = new UITableRow();
ui.addRow(rw);
rw.backgroundColor = new Color('#FFFFFF', 100);
console.log(imgres['title']);
let text = rw.addText(imgres['title'] + ' - xkcd comic viewer');
text.titleColor = new Color('#828282', 100);
// README!!!!!
// How do I make this button re-request xkcd for a random comic, then change the title text on the viewer every time pressed?
let btn = rw.addButton('🔄 Reload');
btn.rightAligned();
// comic here
const comicrw = new UITableRow()
ui.addRow(comicrw)
comicrw.height = 700
const holygrail = comicrw.addImage(img)
holygrail.centerAligned()
ui.present(true);
Thanks for helping!