mirror of https://github.com/bastienwirtz/homer
modify service.js mixin to accept one more parameter and return full response and use this.fetch in PiHole.vue
parent
9e314c960b
commit
ad76093a38
|
@ -169,10 +169,14 @@ export default {
|
||||||
const authenticated = await this.authenticate();
|
const authenticated = await this.authenticate();
|
||||||
if (!authenticated) return;
|
if (!authenticated) return;
|
||||||
}
|
}
|
||||||
|
const options = {
|
||||||
|
method: "GET",
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const response = await this.fetch(`api/stats/summary?sid=${encodeURIComponent(this.sessionId)}`, options, false, true);
|
||||||
|
|
||||||
const url = `${this.endpoint}/${`api/stats/summary?sid=${encodeURIComponent(this.sessionId)}`.replace(/^\/+/, '')}`;
|
|
||||||
const response = await fetch(url);
|
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
if (result?.queries?.percent_blocked !== undefined) {
|
if (result?.queries?.percent_blocked !== undefined) {
|
||||||
|
|
|
@ -12,7 +12,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetch: function (path, init, json = true) {
|
fetch: function (path, init, json = true, returnFullResponse = false) {
|
||||||
let options = {};
|
let options = {};
|
||||||
|
|
||||||
if (this.proxy?.useCredentials) {
|
if (this.proxy?.useCredentials) {
|
||||||
|
@ -58,6 +58,10 @@ export default {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (returnFullResponse) {
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
return json ? response.json() : response.text();
|
return json ? response.json() : response.text();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue