mozilla-magnet / magnet-client

A nearby content discovery client for Android & iOS
Mozilla Public License 2.0
17 stars 10 forks source link

Exception when 'preferences' are `null` #330

Closed wilsonpage closed 7 years ago

wilsonpage commented 7 years ago

My client is throwing:

TypeError: Cannot convert undefined or null to object

On this line: https://github.com/mozilla-magnet/magnet-client/blob/b77a61e/lib/app.js#L196

+@samgiles

wilsonpage commented 7 years ago

I guess this is because my db/datastore hasn't been initialized yet. IIUC we just have to cope with the null case.

samgiles commented 7 years ago

It would be better to not return null if we've created the route. We return a promise so should just resolve later if we're waiting for something to be created.

wilsonpage commented 7 years ago

@samgiles not sure how it works, but I think in this case we're calling .get() before we've populated anything with .post(), thus null.

wilsonpage commented 7 years ago

IIRC empty JSON objects resolve to null in Android, not sure about IOS.

arcturus commented 7 years ago

IIRC empty JSON objects resolve to null in Android, not sure about IOS.

Empy json objects in iOS don't resolve to nil.