Streaming Data With FS2 #2436
Replies: 1 comment 3 replies
-
Usually I'd recommend showing more code, including what imports you have and what codec is used for the JSON decoding. First of all, you're consuming a streaming endpoint, which will keep producing input (I assume) forever, but even if it's short-lived you shouldn't use Roughly something like this: response.body
.covary[IO]
.through(io.circe.fs2.byteStreamParser)
.evalMap(_.as[SampleTweet].liftTo[IO])
.compile
.toList
.unsafeRunSync() btw. for syntactic convenience check out |
Beta Was this translation helpful? Give feedback.
-
Hey 👋🏿
I am trying to stream data from the twitter api
https://api.twitter.com/2/tweets/sample/stream
Ref -
https://developer.twitter.com/en/docs/twitter-api/tweets/sampled-stream/api-reference/get-tweets-sample-stream
For the client I have this
with sample tweet being
but when I make a request, I get this error
expected eof got '{"data...' (line 2, column 1)
There isn't a comma
,
after eachdata
. (I think that is the reason for the error)This makes me think that I am probably not handling the stream well. Please is there a better way to handle streams in
fs2
?Beta Was this translation helpful? Give feedback.
All reactions