diff options
author | Clement Ho <ClemMakesApps@gmail.com> | 2018-02-02 21:34:25 +0300 |
---|---|---|
committer | Clement Ho <ClemMakesApps@gmail.com> | 2018-02-02 21:34:25 +0300 |
commit | 0ba3e84fe4845d1dbc02271dfe97a51968f2bd22 (patch) | |
tree | 661dcb733a37e112a9a3281a03ea2be3756d02bd /app/assets | |
parent | f88fbd2d839629b130ca0d705a70df696c3a3047 (diff) |
Replace $.ajax in username validator with axios
Diffstat (limited to 'app/assets')
-rw-r--r-- | app/assets/javascripts/pages/sessions/new/username_validator.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/app/assets/javascripts/pages/sessions/new/username_validator.js b/app/assets/javascripts/pages/sessions/new/username_validator.js index bb34d5d2008..745543c22da 100644 --- a/app/assets/javascripts/pages/sessions/new/username_validator.js +++ b/app/assets/javascripts/pages/sessions/new/username_validator.js @@ -1,6 +1,9 @@ /* eslint-disable comma-dangle, consistent-return, class-methods-use-this, arrow-parens, no-param-reassign, max-len */ import _ from 'underscore'; +import axios from '~/lib/utils/axios_utils'; +import flash from '~/flash'; +import { __ } from '~/locale'; const debounceTimeoutDuration = 1000; const invalidInputClass = 'gl-field-error-outline'; @@ -77,12 +80,9 @@ export default class UsernameValidator { this.state.pending = true; this.state.available = false; this.renderState(); - return $.ajax({ - type: 'GET', - url: `${gon.relative_url_root}/users/${username}/exists`, - dataType: 'json', - success: (res) => this.setAvailabilityState(res.exists) - }); + axios.get(`${gon.relative_url_root}/users/${username}/exists`) + .then(({ data }) => this.setAvailabilityState(data.exists)) + .catch(() => flash(__('An error occurred while validating username'))); } } |