I have one oDataModel and I am reading a particular property, with read function. When data read is success I am assigning it to a variable. But it is always saying undefined
readData : function(){
var oModel = this.getView().getModel();
var locationID;
oModel.read('/Locations',{
success: function(oData,oResponse){
console.log(oData.results[0].id); //This is printing the data in console, properly
locationID = oData.results[0].id;
}
});
console.log(locationID); //This is printing as undefined
}