Converted milestone.js to axios

This commit is contained in:
Phil Hughes 2018-01-31 09:29:29 +00:00
parent f165bda4ae
commit d58ff9433d
No known key found for this signature in database
GPG Key ID: 32245528C52E0F9F
1 changed files with 8 additions and 10 deletions

View File

@ -1,4 +1,5 @@
import Flash from './flash';
import axios from './lib/utils/axios_utils';
import flash from './flash';
export default class Milestone {
constructor() {
@ -33,15 +34,12 @@ export default class Milestone {
const tabElId = $target.attr('href');
if (endpoint && !$target.hasClass('is-loaded')) {
$.ajax({
url: endpoint,
dataType: 'JSON',
})
.fail(() => new Flash('Error loading milestone tab'))
.done((data) => {
$(tabElId).html(data.html);
$target.addClass('is-loaded');
});
axios.get(endpoint)
.then(({ data }) => {
$(tabElId).html(data.html);
$target.addClass('is-loaded');
})
.catch(() => flash('Error loading milestone tab'));
}
}
}