2
0
mirror of https://github.com/Ionaru/easy-markdown-editor synced 2025-09-24 16:40:55 -06:00

Change Json response to match with Rails

This commit is contained in:
Elvis 2021-12-01 15:27:17 -08:00
parent 5f285cefc2
commit 0fc276c9b3

View File

@ -2379,8 +2379,8 @@ EasyMDE.prototype.uploadImage = function (file, onSuccess, onError) {
onErrorSup(fillErrorMessage(self.options.errorMessages.importError)); onErrorSup(fillErrorMessage(self.options.errorMessages.importError));
return; return;
} }
if (this.status === 200 && response && !response.error && response.data && response.data.filePath) { if (this.status === 200 || this.status === 201 && response && !response.error && response.data && response.data.slug) {
onSuccess((self.options.imagePathAbsolute ? '' : (window.location.origin + '/')) + response.data.filePath); onSuccess((self.options.imagePathAbsolute ? '' : (window.location.origin + '/thumbs/')) + response.data.slug);
} else { } else {
if (response.error && response.error in self.options.errorMessages) { // preformatted error message if (response.error && response.error in self.options.errorMessages) { // preformatted error message
onErrorSup(fillErrorMessage(self.options.errorMessages[response.error])); onErrorSup(fillErrorMessage(self.options.errorMessages[response.error]));