I'm working on a widget for my gear S3 running wearable 3.0 that needs to download json data from a server via the internet. It occurs to me that I've made one assumption that may not be correct. That assumption is that since my watch has an LTE radio that it should be able to access the internet and grab the data. Is this possible?
If it is possible I have another question. The following code worked running in chrome:
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="js/main.js"></script>
<style></style>
</head>
<body>
<div id="page">
<div id="container">
<p id="content-text">sucks</p>
<p> <div>Calories In</div> <div id="calIn">nothing yet</div></p>
</div>
</div>
</body>
<script>
console.log("YYY Starting JSON");
fetch('http://my.url').then(response => {
return response.json();
}).then(data => {
// Work with JSON data here
console.log(data);
//var obj = JSON.parse(data);
console.log(data.caloriesIn);
document.getElementById("calIn").textContent = data.caloriesIn;
}).catch(err => {
// Do something for an error here
});
</script>
</html>
When I ran this code in Tizen studio I receive this error:
console.error: SyntaxError: Unexpected Punctuator '=>'. Expect','
The json data is 3 or 4 fields that I would like to display as a widget. Can anyone help me fix the code I've started or help me find a way to get this to work?