</template>
<script>
+import service from "@/mixins/service.js";
import Generic from "./Generic.vue";
export default {
name: "Ping",
+ mixins: [service],
props: {
item: Object,
},
},
methods: {
fetchStatus: async function () {
- const url = `${this.item.url}`;
- fetch(url, {
- method: "HEAD",
- cache: "no-cache",
- credentials: "include",
- })
- .then((response) => {
- if (!response.ok) {
- throw Error(response.statusText);
- }
+ this.fetch("/", { method: "HEAD", cache: "no-cache" }, false)
+ .then(() => {
this.status = "online";
})
.catch(() => {
}
},
methods: {
- fetch: function (path, init) {
+ fetch: function (path, init, json = true) {
let options = {};
if (this.proxy?.useCredentials) {
if (!response.ok) {
throw new Error("Not 2xx response");
}
- return response.json();
+
+ return json ? response.json() : response;
});
},
},