fix: null reference when parsing error responses (fixes #1749)
This commit is contained in:
@@ -10,9 +10,9 @@
|
||||
<component :is="lens.renderer" :response="response" />
|
||||
</SmartTab>
|
||||
<SmartTab
|
||||
v-if="Object.keys(response.headers).length !== 0"
|
||||
v-if="headerLength"
|
||||
id="headers"
|
||||
:label="`Headers \xA0 • \xA0 ${Object.keys(response.headers).length}`"
|
||||
:label="`Headers \xA0 • \xA0 ${headerLength}`"
|
||||
>
|
||||
<LensesHeadersRenderer :headers="response.headers" />
|
||||
</SmartTab>
|
||||
@@ -31,7 +31,14 @@ export default {
|
||||
response: { type: Object, default: () => {} },
|
||||
},
|
||||
computed: {
|
||||
headerLength() {
|
||||
if (!this.response || !this.response.headers) return 0
|
||||
|
||||
return Object.keys(this.response.headers).length
|
||||
},
|
||||
validLenses() {
|
||||
if (!this.response) return []
|
||||
|
||||
return getSuitableLenses(this.response)
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1626,10 +1626,11 @@ export default {
|
||||
// tests
|
||||
const syntheticResponse = {
|
||||
status: this.response.status,
|
||||
body: this.response.body,
|
||||
headers: this.response.headers,
|
||||
body: this.response.body || new Uint8Array([]),
|
||||
headers: this.response.headers || [],
|
||||
}
|
||||
|
||||
this.response.body = this.response.body || new Uint8Array([])
|
||||
// Parse JSON body
|
||||
if (
|
||||
syntheticResponse.headers["content-type"] &&
|
||||
|
||||
Reference in New Issue
Block a user