diff options
author | Clement Ho <clemmakesapps@gmail.com> | 2018-01-29 20:53:48 +0300 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2018-01-29 20:53:48 +0300 |
commit | f7811b4b0b22b863a25cb285a5972b0925f60969 (patch) | |
tree | b80048995b19c1b207c0d64bf2903559754688ce /app | |
parent | 44edd1111f9ba6dd0dacffad23b54c0c85a723c4 (diff) |
Replace $.post in edit blob with axios
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/blob_edit/edit_blob.js | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/app/assets/javascripts/blob_edit/edit_blob.js b/app/assets/javascripts/blob_edit/edit_blob.js index b37988a674d..a25f7fb3dcd 100644 --- a/app/assets/javascripts/blob_edit/edit_blob.js +++ b/app/assets/javascripts/blob_edit/edit_blob.js @@ -1,5 +1,8 @@ /* global ace */ +import axios from '~/lib/utils/axios_utils'; +import createFlash from '~/flash'; +import { __ } from '~/locale'; import TemplateSelectorMediator from '../blob/file_template_mediator'; export default class EditBlob { @@ -56,12 +59,14 @@ export default class EditBlob { if (paneId === '#preview') { this.$toggleButton.hide(); - return $.post(currentLink.data('preview-url'), { + axios.post(currentLink.data('preview-url'), { content: this.editor.getValue(), - }, (response) => { - currentPane.empty().append(response); - return currentPane.renderGFM(); - }); + }) + .then(({ data }) => { + currentPane.empty().append(data); + currentPane.renderGFM(); + }) + .catch(() => createFlash(__('An error occurred previewing the blob'))); } this.$toggleButton.show(); |