mirror of https://github.com/bastienwirtz/homer
Allow non json reponse in fetch.
parent
efc2bbb856
commit
2fba043575
|
@ -9,10 +9,12 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import service from "@/mixins/service.js";
|
||||||
import Generic from "./Generic.vue";
|
import Generic from "./Generic.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "Ping",
|
name: "Ping",
|
||||||
|
mixins: [service],
|
||||||
props: {
|
props: {
|
||||||
item: Object,
|
item: Object,
|
||||||
},
|
},
|
||||||
|
@ -27,16 +29,8 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchStatus: async function () {
|
fetchStatus: async function () {
|
||||||
const url = `${this.item.url}`;
|
this.fetch("/", { method: "HEAD", cache: "no-cache" }, false)
|
||||||
fetch(url, {
|
.then(() => {
|
||||||
method: "HEAD",
|
|
||||||
cache: "no-cache",
|
|
||||||
credentials: "include",
|
|
||||||
})
|
|
||||||
.then((response) => {
|
|
||||||
if (!response.ok) {
|
|
||||||
throw Error(response.statusText);
|
|
||||||
}
|
|
||||||
this.status = "online";
|
this.status = "online";
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
|
|
@ -12,7 +12,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetch: function (path, init) {
|
fetch: function (path, init, json = true) {
|
||||||
let options = {};
|
let options = {};
|
||||||
|
|
||||||
if (this.proxy?.useCredentials) {
|
if (this.proxy?.useCredentials) {
|
||||||
|
@ -35,7 +35,8 @@ export default {
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error("Not 2xx response");
|
throw new Error("Not 2xx response");
|
||||||
}
|
}
|
||||||
return response.json();
|
|
||||||
|
return json ? response.json() : response;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue