loading

This Plugin Crashed!

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

var req = {
  url: 'https://api.digitransit.fi/realtime/service-alerts/v1/',
  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 service alerts
      if (entity.alert) {
        console.log(JSON.stringify(entity.alert, null, 4));
      }
    });
  }
});
node v10.16.0