mirror of
https://github.com/ThisIsBenny/iOS-Widgets.git
synced 2025-06-07 05:57:41 +00:00
better error handling
Signed-off-by: Benny Samir Hierl <bennysamir@posteo.de>
This commit is contained in:
parent
6a855e70f8
commit
71d0e77df0
1 changed files with 9 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
|||
// Variables used by Scriptable.
|
||||
// These must be at the very top of the file. Do not edit.
|
||||
// icon-color: brown; icon-glyph: magic;
|
||||
// Version 1.1.2
|
||||
// Version 1.1.3
|
||||
|
||||
let widgetInputRAW = args.widgetParameter;
|
||||
let token;
|
||||
|
@ -30,9 +30,14 @@ if (Device.isUsingDarkAppearance()) {
|
|||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
async function getTreeCounter(token) {
|
||||
let req = new Request("https://api.ecosia.org/v1/accounts/personalcounter?token=" + token)
|
||||
try {
|
||||
const url = "https://api.ecosia.org/v1/accounts/personalcounter?token=" + token
|
||||
let req = new Request(url)
|
||||
let res = await req.loadJSON()
|
||||
return parseInt(res.counterValue)
|
||||
} catch (error) {
|
||||
throw new Error('An error occurred when loading data from the Ecosia API. Please check the entered token.')
|
||||
}
|
||||
}
|
||||
|
||||
async function getLogo() {
|
||||
|
|
Loading…
Add table
Reference in a new issue