-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot read property 'decode' of undefined #1
Comments
Here's the full code for inspection:
|
You need to import gtfs-rb by referencing the transit_realtime property. It's a change from the old protobuf.js bindings generator, but this is done to separate namespaces. Ex: This won't work const gtfsRB = require('gtfs-rb')
gtfsRB.FeedMessage // won't work This will: const gtfsRB = require('gtfs-rb').transit_realtime
gtfsRB.FeedMessage // FeedMessage class, with encode/decode/etc. What I do is something more like this keep my code from being cluttered with "gtfsRealtimeBindings.transit_realtime....etc" everywhere: const gtfsRB = require('gtfs-rb').transit_realtime
// Deconstruct these classes from GTFS Realtime Bindings
const { FeedMessage, FeedHeader, FeedEntity, VehiclePosition } = gtfsRB
FeedMessage // valid FeedMessage class with all protobuf message methods |
Ohhh, that works perfectly. Thank you! |
When attempting to use gtfs-rb, on this line:
let feed = GtfsRealtimeBindings.FeedMessage.decode(body);
, I get the errorTypeError: Cannot read property 'decode' of undefined
. This actually wasn't happening with the other repo, but I was getting null values for important information with that one.The text was updated successfully, but these errors were encountered: