diff --git a/packages/insomnia-app/app/ui/components/editors/body/body-editor.js b/packages/insomnia-app/app/ui/components/editors/body/body-editor.js index 8ccebfd69b..33041ddc3f 100644 --- a/packages/insomnia-app/app/ui/components/editors/body/body-editor.js +++ b/packages/insomnia-app/app/ui/components/editors/body/body-editor.js @@ -80,37 +80,37 @@ class BodyEditor extends React.PureComponent { const { onChange, onChangeHeaders, request } = this.props; const headers = clone(request.headers); - let contentTypeHeader = getContentTypeHeader(headers); - - if (!contentTypeHeader) { - contentTypeHeader = { name: 'Content-Type', value: CONTENT_TYPE_FILE }; - headers.push(contentTypeHeader); - } - - // Update Content-Type header if the user wants - const contentType = contentTypeHeader.value; - const newContentType = mimes.lookup(path) || CONTENT_TYPE_FILE; - if (contentType !== newContentType) { - contentTypeHeader.value = newContentType; - showModal(AskModal, { - title: 'Change Content-Type', - message: ( -

- Do you want set the Content-Type header to{' '} - {newContentType}? -

- ), - onDone: saidYes => { - if (saidYes) { - onChangeHeaders(request, headers); - } - }, - }); - } - const newBody = newBodyFile(path); - onChange(request, newBody); + onChange(request, newBody).then(request => { + let contentTypeHeader = getContentTypeHeader(headers); + + if (!contentTypeHeader) { + contentTypeHeader = { name: 'Content-Type', value: CONTENT_TYPE_FILE }; + headers.push(contentTypeHeader); + } + + // Update Content-Type header if the user wants + const contentType = contentTypeHeader.value; + const newContentType = mimes.lookup(path) || CONTENT_TYPE_FILE; + if (contentType !== newContentType && path) { + contentTypeHeader.value = newContentType; + showModal(AskModal, { + title: 'Change Content-Type', + message: ( +

+ Do you want set the Content-Type header to{' '} + {newContentType}? +

+ ), + onDone: saidYes => { + if (saidYes) { + onChangeHeaders(request, headers); + } + }, + }); + } + }); } render() {