Hi,
I am implementing a cart function into my UI5 app to collect a collection of items for further processing. My cart works fine as a feature in my Master-Detail app.
One thing I'd like to add is a counter next to the cart button to inform the user how many items currently are in the cart. My Gateway service happily returns the correct value when I use the $count option. So far, so good.
What I'm struggling with is the
re 1: I decided to retrieve the counter within the onBeforeRendering method. Although I am happy to listen to any advice here.
re 2: I am using the code below.
onBeforeRendering: function() {
var oCountModel = new sap.ui.model.odata.v2.ODataModel("<oData GW service>");
oCountModel.read("/cartSet/$count", {
method: "GET",
async:false,
success: function(data) {
var response = (JSON.stringify(data));
},
error: function() {
}
});
},
The above code call the service synchronous, but doesn't return the service response ("data is undefined"). However, I can see the response later in the Network tab in Chrome.

So basically, the service works and is called, but for some reason I can't seem to get the resulting response.
Any ideas/hints where I am going wrong with this?