I have the following published webapp with code.gs
var queryString
function doGet(e) {
queryString = e.queryString
//logger only works if the return value is commented out
Logger.log(queryString)
return HtmlService.createHtmlOutputFromFile('index.html')
}
function getQueryString() {
// this prints "a=1" on the html
// return "a=1"
// this prints "undefined" on the html
return queryString
}
and index.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<script>
function onSuccess(queryString) {
var div = document.getElementById('output');
div.innerHTML = queryString;
}
</script>
</head>
<body>
<button type="button" onclick="javascript:google.script.run.withSuccessHandler(onSuccess).getQueryString();">show query string</button>
<div id="output"></div>
</body>
</html>
When the button is pressed, the webpage looks as follows

However, I expect the display of the query string. The value of the query string is saved to the global variable queryString during the call of doGet(). Once the user presses the button, the server side function getQueryString should provide the client side html page with the value of the global variable queryString, but it doesn't.
It seems like a new context is generated everytime a server side function is called with newly initialized variables
The use of PropertiesService seems overkill to me. What is the best way to solve that problem?