Hey there! I am just starting out with JS and Vue. Currently, I have a Vue application that pulls date information from an open API. The tricky part is that the API response includes both the date and time in one string (for example: 2019-10-15T09:17:11.808545+02:00
). I'm trying to separate the date from the time at "TO" but haven't been successful so far. Any tips or guidance on how to achieve this would be greatly appreciated. Here's what my current setup looks like:
<template>
<div class="content">
{{split_date(this.date)}}
</div>
</template>
<script>
export default {
mounted() {
axios.get("http://worldtimeapi.org/api/timezone/Europe/Berlin", {})
.then(response => {
this.date = response.data.datetime;
})
.catch((error) => {
console.log(error);
});
},
data() {
return {
date: "",
separated_date: [],
};
},
methods: {
split_date(date) {
this.separated_date = date.split("TO");
return this.separated_date[0];
}
}
}
</script>
Currently, the output displays the entire response: 2019-10-15T09:17:11.808545+02:00
I am also encountering an error message saying:
You may have an infinite update loop in a component render function.