Last active
July 3, 2019 10:39
-
-
Save hartviglarsen/7656df9618afe0f1da819581600ec44c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getProducts() { | |
var url = "url.com/children"; | |
var options = { | |
"method" : "get", | |
"contentType": "application/json" | |
}; | |
var response = UrlFetchApp.fetch(url, options); | |
response = JSON.parse(response); | |
insertProducts(response._embedded.content); | |
} | |
function insertProducts(products) { | |
var data = []; | |
products.map(function (product) { | |
data.push([product.name, product.properties.description]); | |
}); | |
var range = SpreadsheetApp.getActiveSpreadsheet().getRange("A2:B" + (data.length + 1)); | |
range.setValues(data); | |
} | |
function onOpen() { | |
var ui = SpreadsheetApp.getUi(); | |
ui.createMenu("Umbraco") | |
.addItem("Get products", "getProducts") | |
.addToUi(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment