I have been keeping track of various asset prices including crypto on a Google Sheet. One convenient way to fetch crypto prices is by importing data from cryptocurrencies.cc:
=importdata("https://cryptoprices.cc/AION/");
However, I realized that my spreadsheet is now dependent on the cryptoprices.cc website. If it ever goes offline or changes its domain, I would need to manually update every URL in my sheet, which could be quite cumbersome. That's why I came up with an idea to create a wrapper function:
function cryptofinance(token) {
return importdata("https://cryptoprices.cc/"+ token);
}
Unfortunately, this resulted in an error message:
ReferenceError: importdata is not defined (line 94).
It seems like Google Sheet functions cannot be called outside of the Sheets cells, am I correct?
If yes, what is the correct way to utilize the importdata function within this custom function? If no, then what would be the most effective alternative method to retrieve the same information using JavaScript?