Can someone please help me out here. I can’t figure out why I am getting the “Error on line 8:19: Unsupported widget.” error.
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: pink; icon-glyph: thermometer-three-quarters;
const url = 'https://status.slack.com/api/v2.0.0/current';
let req = new Request(url);
let res = await req.loadJSON();
//
// if (config.runsInWidget) {
const widget = createWidget(config.widgetFamily, res);
Script.setWidget(widget);
Script.complete();
// } else {
// if (config.runsInApp) {
// }
// }
async function createWidget(param, res) {
let w = new ListWidget();
// Widget background color
let grad = new LinearGradient();
grad.colors = Device.isUsingDarkAppearance() ?
[new Color('#222'), new Color('#000')] :
[new Color('#FFF'), new Color('#EEE')];
grad.locations = [0, 1];
w.backgroundGradient = grad;
// Widget text
let title = w.addText('Slack Status');
title.font = Font.boldRoundedSystemFont(16);
title.textColor = new Color('#00FF00');
// Status Images
if (res.status == 'ok') {
statusImgUrl = 'https://status.slack.com/img/v2/Ok@2x.png';
} else {
if (res.active_incidents[0].type == 'incident') {
statusImgUrl = 'https://status.slack.com/img/v2/Incident@2x.png';
}
if (res.active_incidents[0].type == 'notice') {
statusImgUrl = 'https://status.slack.com/img/v2/Notice@2x.png';
}
if (res.active_incidents[0].type == 'outage') {
statusImgUrl = 'https://status.slack.com/img/v2/Outage@2x.png';
}
}
const imgReq = new Request(statusImgUrl);
const imgRes = await imgReq.loadImage();
const { width, height } = imgRes.size
const img = w.addImage(imgRes);
img.centerAlignImage();
w.addSpacer();
return w;
}