cancel
Showing results for 
Search instead for 
Did you mean: 

Uncaught TypeError: Cannot read property 'json' of undefined

Mumali
Participant

Hello everyone,

I am a beginner in SAPUI5 attempting to learn using the SAPUI5: The Comprehensive Guide by Modderman et al. I have created a simple application and added data-sap-ui-resourceroots to define the location of files for my namespace. Once I did that, my application failed to load, giving the error shown down below in the console. Anyone that can point me to the right direction will be highly appreciated.

Here my bootstrap code:

        <script id="sap-ui-bootstrap" src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
            data-sap-ui-libs="sap.m" data-sap-ui-theme="sap_bluecrystal" data-sap-ui-preload="async"
            data-sap-ui-compatVersion="edge" data-sap-ui-xx-bindingSyntax="complex" data-sap-ui-resourceroots='{"
            sapui5.demo.mvcapp": "./webapp/"}'>
        </script>

And here is the line where an error occurs:

            // application data
            var oData = {
                "CountSuppliers": "2",
                "Suppliers": [{
                        "ID": 0,
                        "Name": "Exotic Liquids",
                        "Address": {
                            "Street": "NE 228th",
                            "City": "Sammamish",
                            "State": "WA",
                            "ZipCode": "98074",
                            "Country": "USA"
                        }
                    },
                    {
                        "ID": 1,
                        "Name": "Tokyo Traders",
                        "Address": {
                            "Street": "NE 40th",
                            "City": "Redmond",
                            "State": "WA",
                            "ZipCode": "98052",
                            "Country": "USA"
                        }
                    }
                ]
            };
            // model creation and setting data
            var oModel = sap.ui.model.json.JSONModel();
            oModel.setData(oData);
            // setting the model to the core
            // so that it’s available in the whole application
            sap.ui.getCore().setModel(oModel);

Here is the error message:

pablooo860
Explorer

Hi!
I am very glad that you wrote about this problem! I have exactly the same situation... 🙂
The thing is, that removing the piece of code you're writing about - doesn't fix the application.
I think that "src =" resources / sap-ui-core.js "should also be replaced with: "src = "https://sapui5.netweaver.ondemand.com/resources/sap-ui-core.js"?
Didn't you have a problem with that?
Did the application finally work after changing the views to xml?

Regards
Paweł

View Entire Topic
rakototsimba
Member
0 Kudos

Following the same book guide, I just remove the async parameter and it works. remove that: data-sap-ui-preload="async"