0
votes

How to read the object in UI5 with oData V4? Basically I want to get the JSON object from the URL service: enter image description here Ths is my onInit function in the controller.

onInit: function() {
var this_ = this;


this.getView().addEventDelegate({
    onBeforeShow: function(evt) {


        var oModel = new sap.ui.model.json.JSONModel();
        oModel = sap.ui.getCore().getModel("appid");

        var app_id = oModel.getData().app_id;

        this_.getView().bindElement({
            path: "zearnModel>/zearn_summary(" + app_id + ")"
        });

    }
});

}

1

1 Answers

0
votes

From the documentation:

The OData V4 model only supports data access using bindings. It does not provide any direct access to the data.

To get the raw JSON object, all you can do is use jQuery's ajax features to request the data:

$.get({
    url: "<your_service_url>/zearn_summary(" + app_id + ")",
    success: function(data) {
        // your success logic
    },
    error: function(error) {
        // your error logic
    }
});