Hi, i can´t use fetch with an event click. Sounds easy but i can`t
My code:
var Observable = require('FuseJS/Observable');
var modelos = Observable();
var errorMessage = Observable("");
function clickButton() {
fetch("https://vitroappapi.firebaseio.com/.json")
.then((result) => {
if (result.status !== 200) {
errorMessage.value = "Ha ocurrido un error, codigo " + result.status;
return;
}
result.json()
.then((data) => {
debug_log("Success!");
for (var i = 0; i < data.length; i++) {
var items = data[i];
modelos.add(items);
}
});
}).catch((err) => {
errorMessage.value = "Ha ocurrido un error";
});
}
module.exports = {
clickButton: clickButton,
modelos:modelos,
errorMessage: errorMessage
};
Markup UX
<Panel ux:Name="submitButton" Width="100" Offset="0%,50%" Height="50" HitTestMode="LocalBoundsAndChildren" Layer="Layout">
<Text Value="Login" Alignment="Center" Color="White" />
<Clicked Handler >
<Set state.Active="mainState" />
<Callback Handler="{clickButton}" />
</Clicked>
</Panel>
The function clickButton() doesn´t work.