loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.16831321990765336","path":"index.js","file":{"path":"index.js","content":{"asEncoding":{"base64":"dmFyIEd0ZnNSZWFsdGltZUJpbmRpbmdzID0gcmVxdWlyZSgnZ3Rmcy1yZWFsdGltZS1iaW5kaW5ncycpOwp2YXIgcmVxdWVzdCA9IHJlcXVpcmUoJ3JlcXVlc3QnKTsKCmNvbnN0IG9wZXJhdG9yID0gIkhTTCI7Cgp2YXIgcmVxID0gewogIHVybDogJ2h0dHBzOi8vYXBpLmRpZ2l0cmFuc2l0LmZpL3JlYWx0aW1lL3RyaXAtdXBkYXRlcy92MS8nK29wZXJhdG9yLAogIG1ldGhvZDogJ0dFVCcsCiAgZW5jb2Rpbmc6IG51bGwKfTsKCnJlcXVlc3QocmVxLCBmdW5jdGlvbiAoZXJyb3IsIHJlc3BvbnNlLCBib2R5KSB7CiAgaWYgKCFlcnJvciAmJiByZXNwb25zZS5zdGF0dXNDb2RlID09IDIwMCkgewogICAgdmFyIGZlZWQgPSBHdGZzUmVhbHRpbWVCaW5kaW5ncy5GZWVkTWVzc2FnZS5kZWNvZGUoYm9keSk7CiAgICBmZWVkLmVudGl0eS5mb3JFYWNoKGZ1bmN0aW9uKGVudGl0eSkgewogICAgICAvL1ByaW50IG9ubHkgdHJpcCB1cGRhdGVzCiAgICAgIGlmIChlbnRpdHkudHJpcF91cGRhdGUpIHsKICAgICAgICBjb25zb2xlLmxvZyhlbnRpdHkudHJpcF91cGRhdGUudHJpcC50cmlwX2lkKyIgKHJvdXRlOiAiK2VudGl0eS50cmlwX3VwZGF0ZS50cmlwLnJvdXRlX2lkKyIpLCBkZWxheTogIitlbnRpdHkudHJpcF91cGRhdGUuZGVsYXkrInMiKTsKICAgICAgfQogICAgfSk7CiAgfQp9KTs="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var GtfsRealtimeBindings = require('gtfs-realtime-bindings');
var request = require('request');

const operator = "HSL";

var req = {
  url: 'https://api.digitransit.fi/realtime/trip-updates/v1/'+operator,
  method: 'GET',
  encoding: null
};

request(req, function (error, response, body) {
  if (!error && response.statusCode == 200) {
    var feed = GtfsRealtimeBindings.FeedMessage.decode(body);
    feed.entity.forEach(function(entity) {
      //Print only trip updates
      if (entity.trip_update) {
        console.log(entity.trip_update.trip.trip_id+" (route: "+entity.trip_update.trip.route_id+"), delay: "+entity.trip_update.delay+"s");
      }
    });
  }
});
node v10.16.0