headers: { 'X-LC-Id': this.app_id, 'X-LC-Key': this.app_key, 'Content-Type': 'application/json', }, body: JSON.stringify(data) }); }; this.addCount(Counter); }, refreshCounter() { var api_server = this.app_id.slice(-9) !== '-MdYXbMMI' ? this.custom_api_server : `https://${ this.app_id.slice(0, 8).toLowerCase() }.api.lncldglobal.com`; if (api_server) { this.fetchData(api_server); } else { fetch('https://app-router.leancloud.cn/2/route?appId=' + this.app_id) .then(resp => resp.json()) .then(({api_server}) => { this.fetchData('https://' + api_server); }); } } }; LCCounter.refreshCounter(); document.addEventListener('pjax:complete', function () { LCCounter.refreshCounter(); });