Uh oh!
There was an error while loading. Please reload this page.
Rewind draft tutorial - #767
Conversation
tomczoink
left a comment
There was a problem hiding this comment.
Few points, otherwise nicely done
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| subscribeOpenWeather($('select#city-id').val()); | ||
| function subscribeOpenWeather(id) { | ||
| var channelWeather = "[product:ably-openweathermap/weather?rewind=1]weather:" + id; | ||
| var URL = `https://realtime.ably.io/sse?v=1.1&key=${apiKey}&channels=${channelWeather}`; |
There was a problem hiding this comment.
If you want to include a channel name with params in the name, you need to uri-encode it, which you're not doing here. A much easier way is just to add rewind=1 as another url param. This is explained in the documentation pr:
https://github.com/ably/docs/pull/729/files#diff-7b572e68f8441588d6eacc180bc8f989R76-R89
There was a problem hiding this comment.
(to explain this a bit further: the reason this is especially necessary here is that question marks have special meaning in urls, they start the query string ("/sse?v=..."). Maybe in some browsers having subsequent question marks inside the query string will work, but it's not guaranteed to work in all of them. The correct/safe thing to do that will work in all browsers is uri-encode them. (Really this should be done for all api streamer sse examples -- the brackets and forwardslash in [product:foo/bar]baz are technically also disallowed, though again, will probably work in some browsers))
No description provided.