How to return more than 10000 items with a loop?

Hi! So I have the following code to loop through the search catalog

   const limit = 200
   for (var i = 0; i <= priceLength; i += limit) {
      const body = {
        filters: [
          {
             values: [""],
             name: "ProductName",
          },
        ],
        offset: i,
        limit: limit,
      };
      // looped code
   }

It works as intended, but once the offset reaches 10,000, it starts returning errors instead of results. Why is that, and how can I get around it?

What does the error say?