'Solidity view returns an error of 'out of gas'

When running a public view function that I deployed to etherscan testnet, I get the following error:

Returned error: out of gas

I have a forloop that loops 500 times which I assume is taking too long. Is there any ways counteract it taking a long time to process?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source