In my Vue website, I have a function that makes a call and gets an object with a date in the response.data:
Here is an example of an object in response.data
:
response.data = {available_at: '2019-08-12', title: 'Test'}
Currently, I am fetching this data and creating an array called dates
using this.dates
, which is working fine. But, I want to check if the value of response.data.available_at
is equal to the current date. If it matches, then add it to this.dates
; otherwise, add it to this.pastDates
.
Is there a way to modify my code to achieve this?
fetch() {
axios.get('/items/')
.then(response => {
// handle success
console.log(response.data)
this.dates = response.data
})
.finally(function() {})
}
UPDATE: The structure of response.data (a list of objects)
(51) [{…}, {…}, {…}, {…},...]
0:
available_at: "2019-09-16"
title: "2"