0
votes

I'm trying to fetch some data to a google sheet. The code goes like this:

function ls() {
var url = "https://api.loanscan.io/v1/interest-rates?tokenFilter=BTC";
var params = {
         "contentType": "application/json",
         "headers":{"x-api-key": "KEY",
                    },

         };

var json = UrlFetchApp.fetch(url, params);
var jsondata=json.getContentText();
var page = JSON.parse(jsondata);
Logger.log page
return page;

}

The Logger.log gives the correct Data, as you can see in the next link.

Log

However when I run the function in the google sheet, it returns a blank cell.

Please help, thank you.

1
You need to learn to mould the data to a 2d array. Look into importjson script.TheMaster

1 Answers

0
votes

You should write the Logger.log(page); with parentheses, because sheets is probably hanging on your Logger statement. I don't have an API key for that site, but I do get the forbidden error response from the API when using =ls() in a cell in sheets.