In the vue block below, I have successfully pushed my response data into the dateEvents
return. Additionally, I am rendering events for a calendar package I am using. My goal is to map my response data to the events object where the name
becomes the event title
and the available_at
corresponds to the event start
.
To elaborate, the response data looks like this:
[name:"test one", available_at:"2019-09-25"][name:"test two", available_at:"2019-09-25"]
. Therefore, I want to take the response.data
that is being pushed into my events
array and use the name
as the title
and available_at
as the start
. While I am able to retrieve and display the dateEvents
, I am unsure of how to format them in this manner for events.
export default {
data() {
return {
dateEvents: [],
events: [
{
title: 'test',
start: '2019-08-17',
},
{
title: 'another test',
start: '2019-08-20',
},
],
config: {
defaultView: 'month',
editable: true,
eventRender: function(event, element) {
console.log(event)
},
},
}
},
created() {
this.fetchTasks()
},
methods: {
fetchTasks() {
axios
.get('/dashboard/tasks')
.then(response => {
// handle success
console.log(response.data)
this.dateEvents = response.data
this.events = response.data
})
.catch(function(error) {
// handle error
console.log(error)
})
.finally(function() {})
},
},
}