How do you obtain customer information in a JavaScript module?
A. Magento does not expose customer information in JavaScript for security reasons
B. By sending an AJAX request to the url: /customer/account/info/?json=1
C. By using customerData.get(‘customer’) call, where customerData is an instance of Magento_Customer/js/customer-data
D. Customer information is available in localStorage and be retrieved by calling window.localStorage.getItem(‘customer’)
Answer:- C
define([
‘uiComponent’,
‘Magento_Customer/js/customer-data’
], function (Component, customerData) {
‘use strict’;
return Component.extend({
initialize: function () {
this._super();
this.customer = customerData.get(‘customer’);
}
});
});
Correct Answer: C