Having trouble displaying all the user IDs and creation dates within a specific date range in a table. I'm struggling with filtering the data based on dates. Can someone help me identify what I might be doing wrong? I've attempted to replicate the API response in the data state, then filter that data to retrieve information from a certain date range. The console statement doesn't seem to work inside the getDateData method in this code sandbox demo
<template>
<div @click="getDateData">Hello</div>
</template>
<script>
export default {
data() {
return {
newData: {},
usersFromDb: {
data: {
users_by_id: {
users: [
{
id: "123",
created_at: "2021-04-14T12:24:27.577Z",
},
{
id: "456",
created_at: "2021-04-14T12:24:27.577Z",
},
],
},
},
},
};
},
methods: {
getDateData() {
const fromDate = "2021-04-14T12:24:27.577Z";
const toDate = "2021-04-14T14:17:13.127Z";
this.newData = this.usersFromDb.forEach((item) => {
console.log(item.users_by_id.users.created_at);
return (
item.date.getTime() >= fromDate.getTime() &&
item.date.getTime() <= toDate.getTime()
);
});
},
},
};
</script>