mirror of
https://github.com/YMFE/yapi.git
synced 2025-03-07 14:16:52 +08:00
fix: response not json
This commit is contained in:
parent
0fb6f7bbe1
commit
235b6c2674
@ -145,7 +145,9 @@ export default class Run extends Component {
|
||||
files: bodyType === 'form' ? this.getFiles(bodyForm) : {},
|
||||
success: (res, header) => {
|
||||
try {
|
||||
res = typeof res === 'object' ? res : JSON.parse(res)
|
||||
if (header['content-type'].indexOf('application/json') !== -1) {
|
||||
res = typeof res === 'object' ? res : JSON.parse(res)
|
||||
}
|
||||
header = typeof header === 'object' ? header : JSON.parse(header)
|
||||
} catch (e) {
|
||||
message.error(e.message)
|
||||
@ -157,7 +159,9 @@ export default class Run extends Component {
|
||||
},
|
||||
error: (err, header) => {
|
||||
try {
|
||||
err = typeof err === 'object' ? err : JSON.parse(err)
|
||||
if (header['content-type'].indexOf('application/json') !== -1) {
|
||||
err = typeof err === 'object' ? err : JSON.parse(err)
|
||||
}
|
||||
header = typeof header === 'object' ? header : JSON.parse(header)
|
||||
} catch (e) {
|
||||
message.error(e.message)
|
||||
@ -606,7 +610,7 @@ export default class Run extends Component {
|
||||
<Panel header="BODY" key="0" >
|
||||
<div id="res-body-pretty" className="pretty-editor" style={{display: isResJson ? '' : 'none'}}></div>
|
||||
<TextArea
|
||||
style={{display: isResJson ? 'none' : ''}}
|
||||
style={{display: isResJson ? 'none' : ''}}
|
||||
value={typeof this.state.res === 'object' ? JSON.stringify(this.state.res, null, 2) : this.state.res.toString()}
|
||||
autosize={{ minRows: 2, maxRows: 10 }}
|
||||
></TextArea>
|
||||
|
Loading…
Reference in New Issue
Block a user