Converted usage_ping.js to use axios

also removed dependancy on jQuery because it is super simple & not required
This commit is contained in:
Phil Hughes 2018-02-01 11:18:01 +00:00
parent ee1c471bad
commit 43f1088f5b
No known key found for this signature in database
GPG key ID: 32245528C52E0F9F

View file

@ -1,12 +1,13 @@
export default function UsagePing() {
const usageDataUrl = $('.usage-data').data('endpoint');
import axios from '../../../lib/utils/axios_utils';
import { __ } from '../../../locale';
import flash from '../../../flash';
$.ajax({
type: 'GET',
url: usageDataUrl,
dataType: 'html',
success(html) {
$('.usage-data').html(html);
},
});
export default function UsagePing() {
const el = document.querySelector('.usage-data');
axios.get(el.dataset.endpoint, {
responseType: 'text',
}).then(({ data }) => {
el.innerHTML = data;
}).catch(() => flash(__('Error fetching usage ping data.')));
}