Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- by mvan231
- */
- let localFm = FileManager.local()
- let cachePath = localFm.documentsDirectory()
- let data;
- let usingCachedData = false;
- let cache = localFm.joinPath(cachePath, "lastread")
- try {
- log('trying')
- data = await new Request("https://pastebin.com/raw/iE1BzSpQ").loadString()
- localFm.writeString(cache, data)
- } catch(e) {
- console.log("Offline mode")
- data = localFm.readString(cache);
- usingCachedData = true
- }
- let widget = new ListWidget();
- widget.addText(`usingCachedData value is ${usingCachedData}`)
- widget.addText(`data value is: ${data}`)
- Script.setWidget(widget)
- Script.complete()
- widget.presentMedium()
Advertisement
Add Comment
Please, Sign In to add comment