My objective involves making requests to an API for transactions and saving them to a database. The API response is paginated, so I need to read each page and save the transactions in batches.
After one request/response cycle, I aim to process the data and store it in the database before moving on to fetch the next batch of transactions.
In an effort to stay testable, I am using the actual HTTP fetch call as
(url:string, init:RequestInit) => TE.TaskEither<Error, Response>
within fp-ts. How can I achieve this in a more idiomatic way?
I have experimented with RxJS and fp-ts, but encountered complexity despite eventually getting it to work.
I've tried implementing both recursive functions and generators, yet I'm struggling to achieve lazy evaluation.
Are there any existing examples in fp-ts that demonstrate a lazily evaluated stream where each element depends on the previous one?