Skip to content

Instantly share code, notes, and snippets.

@HOLLIX
Created July 2, 2022 16:26
Show Gist options
  • Save HOLLIX/74d7679c18bf495694fb41d7ee0a805e to your computer and use it in GitHub Desktop.
Save HOLLIX/74d7679c18bf495694fb41d7ee0a805e to your computer and use it in GitHub Desktop.
Fetch JSON Data
onInit: function () {
const sUrl = "https://api.coinbase.com/v2/currencies",
oJSONModel = new JSONModel({
list: [],
busy: true,
busyIndicatorDelay: 0
});
this.setModel(oJSONModel);
jQuery.get(sUrl).then(oData => {
oJSONModel.setProperty("/list", oData.data);
}).fail(() => {
oJSONModel.setProperty("/list", []);
}).always(() => {
oJSONModel.setProperty("/busy", false);
})
}
<Page busy="{/busy}" busyIndicatorDelay="{/busyIndicatorDelay}">
<List items="{/list}">
<StandardListItem title="{name}"/>
</List>
</Page>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment