简体   繁体   中英

How to handle a large amount of JSON from a URL

I use an API that shows a product's information, but I would like to get all of them -- there are over 75,000 products. When I open URL that shows the JSON, my browser just keeps loading.

Can someone me help me to retrieve all of the products as fast as possible using Laravel 5.2?

Below should be the controller code:

return view('Product.List')->with('Products', $Countries->getData()->Data);
                                                           ^^^^^^^^^^^^^^^
But I am not sure if this is correct way to fix this issue. I am reading JsonResponse.

I think the best thing to do in your case is using limit and offset in your queries to that server and you could use lazy load and ajax , pagination or other methods to retrieve data from the offset with limit.

This make your program more efficient and fast and on the other hand, you don't confuse your user with a sudden huge amount of data on the screen.

Edit: You could provide more information about the API and the method to access it to get better help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM