Fixed small changes in the Ecosia API

- URL of Ecosia adapted due to changes in the API
- Changed key from JSON map due to changes in the API
This commit is contained in:
Fuly 2021-04-30 13:35:29 +02:00 committed by GitHub
parent 4a40b1895f
commit 623f903399
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -34,10 +34,10 @@ if (Device.isUsingDarkAppearance()) {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
async function getTreeCounter(token) { async function getTreeCounter(token) {
try { try {
const url = "https://api.ecosia.org/v1/accounts/personalcounter?token=" + token const url = "https://api.ecosia.org/v1/accounts/v2/personal_counter?token=" + token
let req = new Request(url) let req = new Request(url)
let res = await req.loadJSON() let res = await req.loadJSON()
return parseInt(res.counterValue) return parseInt(res.personal_counter)
} catch (error) { } catch (error) {
throw new Error('An error occurred when loading data from the Ecosia API. Please check the entered token.') throw new Error('An error occurred when loading data from the Ecosia API. Please check the entered token.')
} }