I've created the code below to catch data from an online JSON file. This file contains a lot of data which has the property PubDate. There are also items with other dates. What I'm trying to do, is to catch all items which have the same PubDate as today.
But in Chrome developer tools, I get the message "data.filter is not a function". What am I doing wrong? And am I eventually missing something between the words "data" and "filter" in data.filter?
//Catch JSON Data
let data;
data = fetch('https://online.192tv.tv/Backend.svc/getepg')
.then(response => response.json())
.then(items => console.log(items));
// Get date and time
let today = new Date();
let time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
// Find items for today
var data_today;
data.filter(function (el) {
data_today.push(el.PubDate == today);
});
I have the data from https://online.192tv.tv/Backend.svc/getepg and when I send it to the console it looks like this:
{MetaData: Array(157), PerformanceCost: 0, ResultMessage: "OK", ServerTime: "2021-06-03T20:16:01.1531591+02:00", SessionId: "g1qxdqzqpevmd4gp4eogpj4b", …}
MetaData: Array(157)
[0 … 99]
0:
Actors: []
AnimatedGif: ""
AvailableWebApp: true
Categories: []
Category: ""
ContentType: ""
Description: "Nachtklup, de beste clips om de nacht te eindigen...of beginnen?"
Directors: []
EndPubDate: "2021-05-29T02:00:00.0000000"
FromPrice: 0
GroupLevel: -1