Magento – Magento 2: Customer data from JS component

frontendjavascriptmagento2uicomponent

I need to get customer status in JS component – authenticated or anonymous. Could I get it using Magento_Customer/js/customer-data and how?

define([
    'Magento_Customer/js/customer-data'
], function (customerData) {
    let isAnon = customerData.???
});

Best Answer

Yes, use customerData.get(property) where property is what you want to get. Example:

customerData.get('customer')
Related Topic