Makes sure it do not crashes when polling.
This commit is contained in:
@@ -11,9 +11,15 @@ export const handle: ServiceHandler = async (config: ServiceConfig) => {
|
||||
config.url + '/api.php?summaryRaw&auth=' + config.api_token
|
||||
);
|
||||
res.status = resp.ok ? 'online' : 'offline';
|
||||
res.raw = resp.json();
|
||||
const raw = await resp.json();
|
||||
res.data = {
|
||||
queries_today: raw.dns_queries_today,
|
||||
ads_percentage: raw.ads_percentage_today,
|
||||
status: raw.status,
|
||||
client: raw.unique_clients
|
||||
};
|
||||
} catch (error) {
|
||||
res.status = undefined;
|
||||
res.status = 'offline';
|
||||
console.warn('could not fetch pihole status: ' + error);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user