I'm fairly new to JavaScript and AlaSQL, so sorry if this is obvious.
I'm trying to save the result of my AlaSQL query to a variable so I can use it elsewhere in my code. As a bit of context, I'm querying a CSV file, and I'm wanting to get the max, min and a certain row of a particular column, so I can then use this elsewhere. At the moment I'm just trying it on the max aspect.
<script>
alasql.promise('VALUE OF SELECT MAX(PM1) FROM CSV("http://localhost:8000/assets/interpolated.csv", {separator:","})').then(function(res){console.log(res); document.getElementById("testingId5").innerHTML = res}).catch(function(err){console.log('Error:', err);});
</script>
This produces a result and logs it in the console, and shows it onscreen, but I want to set it to a variable to be able to use too!
I've tried just adding var test = res;
within the .then(function(res){})
part, but with no luck.
Thanks in advance.