Magento 2 – TypeError: options is Undefined (customer-data.js)

errormagento2

I'm building a custom Magento theme that relies on a couple of third party JS libraries (slick, bootstrap) and I've suddenly hit a problem that I cannot figure out.
When on the homepage I receive the error:

TypeError: options is undefined

In the customer-data.js file on line 85:

return $.getJSON(options.sectionLoadUrl, parameters).fail(function (jqXHR) {

This only happens on the homepage and any other page such as search results I do not receive this error, this leads me to believe it is the cause of some third party js on the homepage conflicting.

The shopping cart and Bootstrap.js stop working due to this error but slick slider continues to work fine. I've tried removing all code related to Slick and temporarily removed it from the RequireJS-Config file however this didn't change anything 🙁

Here's a link to the site in progress: removed

If anybody has had any experience with this any input would be much appreciated.

Best Answer

The resolution for me was removing the following line:

<referenceBlock name="content" display="false"/>

I put this in to hide the CMS content of the page however it caused the following script:

<script type="text/x-magento-init">{"*":{"Magento_Customer\/js\/customer-data":{"sectionLoadUrl":"http:\/\/magento-2-1-4.dev\/customer\/section\/load\/","cookieLifeTime":"3600","updateSessionUrl":"http:\/\/magento-2-1-4.dev\/customer\/account\/updateSession\/"}}}</script>

To not load, thus causing the error. I guess i'll find another method to hide CMS content

Related Topic