I am using Script lab in office 365 and facing difficulty in writing a function which fetches data from API(url). I need help in merging the below code with custom function in Java Script.
from the below code that I am able to get API results in script lab console but I want final results in excel screen(cell). Currently I can see all the ticker.name instead of specific.
var request = new XMLHttpRequest();
request.open("GET", "https://api.coinmarketcap.com/v1/ticker/", true);
request.onload = function() {
// Begin accessing JSON data here
var data = JSON.parse(this.response);
if (request.status >= 200 && request.status < 400) {
data.forEach((ticker) => {
console.log(ticker.name, ticker.rank);
});
} else {
console.log("error");
}
};
request.send();
For final result I should type =coinmarket.rank(bitcoin) in excel cell and the result should show me the rank of bitcoin from the list of other crypto currencies