I know similar questions have been asked here before, but I didn't find an answer that helped me. Sorry for that! I'm probably just too inexperienced to understand those answers, so please bear with me.
I have written a Google Apps Script that scans a specific Spreadsheet (not authored by me, but I can view) and counts certain fields. The doGet(e) function returns the count, so when I run the published-as-web-app I see a number.
Now from my background.js in my chrome extension I did something like this:
var my_app = "https://script.google.com/a/macros/google.com/s/.../exec?param=value";
var xhr = new XMLHttpRequest();
try {
xhr.open("GET", my_app);
xhr.send(null);
var result = xhr.getAllResponseHeaders();
localStorage.count = result;
chrome.browserAction.setBadgeText({text: localStorage.count});
} catch(e)
...
}
This is very rough, since I'm very new to JavaScript and Chrome Extensions and such.
I'm guessing getAllResponseHeaders() is not how I get to the resulting number that is displayed when calling my_app, so what should I use instead? In the API reference for XMLHttpRequest I didn't find anything obvious.
I'm pretty sure there's a lot more wrong with my code, but let's go one step at a time.
Thanks already in advance! Detailed answers would be great, so I can follow them and extend my currently very limited knowledge.