Hello, I normally speak German and have translated this.
I am just starting with MIT App Inventor.
I need to implement something that queries a web API.
But I just don't know which blocks to use.
I have a button to trigger the action and two text fields to display the results.
I have received the code, but I don’t know how to modify it.
Can someone help me with this? I've been trying for hours.
Thank you.
Here is the code:
function getData() {
var requestObj = {};
requestObj.getvars = [ ];
var toget = { "var": "(A:PLANE ALTITUDE, Feet)", "value": 0 };
requestObj.getvars.push(toget);
toget = { "var": "(A:GROUND VELOCITY, Knots)", "value": 0 };
requestObj.getvars.push(toget);
var xhttp = new XMLHttpRequest();
xhttp.addEventListener("load", dataRequestListener);
xhttp.open("GET", AAO_URL + "?json=" + JSON.stringify(requestObj));
xhttp.send();
}
function dataRequestListener() {
var commObj = JSON.parse(this.responseText);
var myalt = commObj.getvars[0].value;
var myspeed = commObj.getvars[1].value;
}