(function() {

        window.addEventListener('bp.api.data.fetched', function(e) {
        const elements = document.body.querySelectorAll('[data-bp-type="' + e.detail.type + '"]');
        elements.forEach(function(el) {
            el.innerHTML = e.detail.data;
        });
    });
    
    fetch('https\u003A\/\/api.baseplus.de\/claim\u003Ftoken\u003DlKv8m8LRIvz5bi46wC\u0025252FRvgX6wFNxFI5Gxa4FDeCkOrYuQpVyeX7AWKQb7Mn658YDscLXpiffKWP4BBUmB9t5aw\u0025253D\u0025253D', {
        method: 'get'
    })
        .then(response => response.json())
        .then(json => {
            if ('ok' !== json.status.toLowerCase()) {
                console.error('Error in request.');
                return false;
            }

            const event = new CustomEvent('bp.api.data.fetched', {
                bubbles: true,
                detail: {
                    type: 'claim',
                    data: json.response
                }
            });
            window.dispatchEvent(event)
        });

    fetch('https\u003A\/\/api.baseplus.de\/address\u003Ftoken\u003DlKv8m8LRIvz5bi46wC\u0025252FRvgX6wFNxFI5Gxa4FDeCkOrYuQpVyeX7AWKQb7Mn658YDscLXpiffKWP4BBUmB9t5aw\u0025253D\u0025253D', {
        method: 'get'
    })
        .then(response => response.json())
        .then(json => {
            if ('ok' !== json.status.toLowerCase()) {
                console.error('Error in request.');
                return false;
            }

            const event = new CustomEvent('bp.api.data.fetched', {
                bubbles: true,
                detail: {
                    type: 'address',
                    data: json.response
                }
            });
            window.dispatchEvent(event)
        });
})();
