Commit 797f29d1 authored by Phil Hughes's avatar Phil Hughes

converted compare_autocomplete to axios

parent 9846332f
/* eslint-disable func-names, space-before-function-paren, one-var, no-var, one-var-declaration-per-line, object-shorthand, comma-dangle, prefer-arrow-callback, no-else-return, newline-per-chained-call, wrap-iife, max-len */ /* eslint-disable func-names, space-before-function-paren, one-var, no-var, one-var-declaration-per-line, object-shorthand, comma-dangle, prefer-arrow-callback, no-else-return, newline-per-chained-call, wrap-iife, max-len */
import axios from './lib/utils/axios_utils';
import flash from './flash';
export default function initCompareAutocomplete() { export default function initCompareAutocomplete() {
$('.js-compare-dropdown').each(function() { $('.js-compare-dropdown').each(function() {
...@@ -10,15 +12,14 @@ export default function initCompareAutocomplete() { ...@@ -10,15 +12,14 @@ export default function initCompareAutocomplete() {
const $filterInput = $('input[type="search"]', $dropdownContainer); const $filterInput = $('input[type="search"]', $dropdownContainer);
$dropdown.glDropdown({ $dropdown.glDropdown({
data: function(term, callback) { data: function(term, callback) {
return $.ajax({ axios.get($dropdown.data('refsUrl'), {
url: $dropdown.data('refs-url'), params: {
data: {
ref: $dropdown.data('ref'), ref: $dropdown.data('ref'),
search: term, search: term,
} },
}).done(function(refs) { }).then(({ data }) => {
return callback(refs); callback(data);
}); }).catch(() => flash('Error fetching refs'));
}, },
selectable: true, selectable: true,
filterable: true, filterable: true,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment