How to fix the «Uncaught TypeError: Cannot convert undefined or null to object in customer-addresses.js:20» Magento 2 bug?

It is Magento 2.0.x and Magento 2.1.x bug.

How to fix

Locate the line:
https://github.com/magento/magento2/blob/2.1.8/app/code/Magento/Customer/view/frontend/web/js/model/customer-addresses.js#L18-L18

Replace it with the following one:

if (isLoggedIn()) {

It is already fixed in the Magento 2.2:
https://github.com/magento/magento2/blob/2.2.0-rc2.2/app/code/Magento/Customer/view/frontend/web/js/model/customer-addresses.js#L26-L26

https://github.com/magento/magento2/commit/0195c22e

https://github.com/magento/magento2/issues/7115

https://github.com/amzn/amazon-payments-magento-2-plugin/issues/36

The issue is fixed in Magento 2.2.0:

github.com/magento/magento2/issues/7115#issuecomment-331000497