i have a problem since i want to get multiple data from a single api call How can i return more than one value from it? I'm running this function, it create the correct logs, but not the return part.
function getParts(axieID) {
const response = UrlFetchApp.fetch(`https://api.axie.technology/getaxies/${axieID}`);
const data = JSON.parse(response.getContentText());
try {
Logger.log(data.class)
Logger.log(data.parts[1].name)
return {
total: data.class
}, {
total1: data.parts[1].name
};
} catch (e) {
Logger.log(e)
return {
total: 'error',
total1: 'error'
}
}
}
EDIT
var {total} = getParts(axieID);
if (total != 'error') {
sh3.getRange('J'+counter).setValue(total);
}
Utilities.sleep(700)
}
var {total1} = getParts(axieID);
if (total1 != 'error') {
sh3.getRange('K'+counter).setValue(total1);
}
Utilities.sleep(700)
SOLUTION (total changed with classe, and total1 changed with orecchie):
function getParts(axieID) {
const response = UrlFetchApp.fetch(`https://api.axie.technology/getaxies/${axieID}`);
const data = JSON.parse(response.getContentText());
try {
Logger.log(data.class)
Logger.log(data.parts[1].name)
return {classe : data.class, orecchie : data.parts[1].name};
}
catch (e) {
Logger.log(e)
return {
classe: 'error', orecchie: 'error'
}
}
}
var {classe,orecchie} = getParts(axieID);
if (classe != 'error') {
sh3.getRange('J'+counter).setValue(classe);
}
if (orecchie != 'error') {
sh3.getRange('K'+counter).setValue(orecchie);
}
Utilities.sleep(700)
}