Screenshot of fox image generated in spreadsheet |
Initially this Function calls connectAPI (below) to get data from the RandomFox API website. 2 items are returned (a link and an image) from which we just want the image part of the data:
var imageResult = data['image'];We then need to get this into the spreadsheet for which we can create a formula tha uses the image Url we now have:
var formula = "=image(\"" + imageResult + "\")";
imageCell.setValue(formula);
connectAPI.gs
This Function access the RandomFox API and returns the data to the parent Function (above) in a usable format:
var response = UrlFetchApp.fetch(url);Access RandomFox API for images download
var json = response.getContentText();
var data = JSON.parse(json);
No comments:
Post a Comment