Skip to content

Commit bc23dd7

Browse files
committed
Hotfix: 204 hangs api tester.
1 parent a655183 commit bc23dd7

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

resources/assets/js/components/edit-block/edit-block.vue

+17-11
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
import vmRequestEditor from './request-editor/request-editor.vue'
1212
import vmResponseViewer from './response-viewer/response-viewer.vue'
1313
14-
import {scheduleRequest, setRequestInfo, setResponse} from '../../vuex/actions.js'
14+
import {
15+
scheduleRequest,
16+
setRequestInfo,
17+
setResponse
18+
} from '../../vuex/actions.js'
1519
import RandExp from 'randexp'
1620
import requestEditorData from './request-editor/request-editor-data.js'
1721
@@ -51,9 +55,8 @@
5155
// Modifies path if wheres are declared in request.
5256
// Otherwise, we'll send to unmodified path.
5357
54-
console.log(request.wheres)
5558
let path = request.url
56-
if(request.wheres){
59+
if (request.wheres) {
5760
let wheres = request.wheres
5861
for (let index in wheres) {
5962
let mocker = new RandExp(new RegExp(wheres[index]))
@@ -64,12 +67,12 @@
6467
}
6568
6669
// Do sending.
67-
this.$api.ajax(request.method, path, request.data, request.headers).then((response) => {
68-
this.setRequestInfo(response.data)
69-
this.setInfoError(false)
70-
}).catch((xhr) => {
71-
this.setInfoError(xhr.status)
72-
})
70+
this.$api.ajax(request.method, path, request.data, request.headers)
71+
.then((response) => {
72+
this.setRequestInfo(response.data)
73+
this.setInfoError(false)
74+
})
75+
.catch(xhr => this.setInfoError(xhr.status))
7376
},
7477
send (request){
7578
request = this.prepareRequest(request)
@@ -91,8 +94,11 @@
9194
getResult(request, redirects){
9295
this.$api.ajax(request.method, request.url, request.data, request.headers)
9396
.always(function (dataOrXHR, status, XHROrError) {
97+
98+
let isXHR = dataOrXHR && dataOrXHR.hasOwnProperty('responseText')
99+
94100
// NOTE Jquery ajax is sometimes not quite sane.
95-
let xhr = dataOrXHR.hasOwnProperty('responseText') ? dataOrXHR : XHROrError
101+
let xhr = isXHR ? dataOrXHR : XHROrError
96102
let data = xhr.responseText
97103
try {
98104
data = JSON.parse(data)
@@ -153,7 +159,7 @@
153159
},
154160
// We work with scheduled requests as with stack.
155161
scheduledRequests (requests){
156-
if (requests.length === 0){
162+
if (requests.length === 0) {
157163
return
158164
}
159165

0 commit comments

Comments
 (0)