Is there a simple way to parse a JSON with TAU library? I couldn't find any solution.
I'm trying to get data from alphavantage api and display it: www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=MSFT&apikey=demo
I've tried XMLhttprequest and Jquery and none seems to work with Tizen Web App.
After setting up the config.xml as recommended above by @Patryk Falba,
I've come up with two working options:
Using fecth()
if (self.fetch) {
console.log("Fetching...")
fetch('https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=MSFT&apikey=demo')
.then(response => response.json())
.then(data => {
console.log(data['Global Quote']['01. symbol'])
})
} else {
console.log("Something went wrong...")
}
Using XMLHttpRequest()
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var myObj = JSON.parse(this.responseText);
console.log("Ok!");
console.log(myObj['Global Quote']['01. symbol']);
}
};
xmlhttp.open('GET', 'https://www.alphavantage.co/query?function=GLOBAL_QUOTE&symbol=MSFT&apikey=demo', true);
xmlhttp.send();