diff --git a/components/lenses/renderers/mixins/TextContentRendererMixin.js b/components/lenses/renderers/mixins/TextContentRendererMixin.js index 30f31f517..805276498 100644 --- a/components/lenses/renderers/mixins/TextContentRendererMixin.js +++ b/components/lenses/renderers/mixins/TextContentRendererMixin.js @@ -4,6 +4,7 @@ export default { }, computed: { responseBodyText() { + if (typeof this.response.body === "string") return this.response.body return new TextDecoder("utf-8").decode(this.response.body) }, }, diff --git a/helpers/strategies/AxiosStrategy.js b/helpers/strategies/AxiosStrategy.js index 583cdcd19..76180b72b 100644 --- a/helpers/strategies/AxiosStrategy.js +++ b/helpers/strategies/AxiosStrategy.js @@ -23,6 +23,10 @@ const axiosWithProxy = async (req, { state }) => { } ) + if (!data.data.success) { + throw new Error(data.data.message || "Proxy Error") + } + if (data.isBinary) { data.data = decodeB64StringToArrayBuffer(data.data) } diff --git a/helpers/strategies/ExtensionStrategy.js b/helpers/strategies/ExtensionStrategy.js index c98204c35..b96737e28 100644 --- a/helpers/strategies/ExtensionStrategy.js +++ b/helpers/strategies/ExtensionStrategy.js @@ -25,11 +25,17 @@ const extensionWithProxy = async (req, { state }) => { }, }) - if (data.isBinary) { - data.data = decodeB64StringToArrayBuffer(data.data) + const parsedData = JSON.parse(data) + + if (!parsedData.data.success) { + throw new Error(parsedData.data.message || "Proxy Error") } - return data + if (parsedData.isBinary) { + parsedData.data = decodeB64StringToArrayBuffer(data.data) + } + + return parsedData } const extensionWithoutProxy = async (req, _store) => { diff --git a/pages/graphql.vue b/pages/graphql.vue index 33b9f8511..b7d6d8711 100644 --- a/pages/graphql.vue +++ b/pages/graphql.vue @@ -528,7 +528,7 @@ export default { const res = await sendNetworkRequest(reqOptions, this.$store) - const responseText = new TextDecoder("utf-8").decode(new Uint8Array(res.data)) + const responseText = new TextDecoder("utf-8").decode(res.data) this.response = JSON.stringify(JSON.parse(responseText), null, 2) @@ -629,7 +629,7 @@ export default { const data = await sendNetworkRequest(reqOptions, this.$store) - const response = new TextDecoder("utf-8").decode(new Uint8Array(data.data)) + const response = new TextDecoder("utf-8").decode(data.data) const introspectResponse = JSON.parse(response) const schema = gql.buildClientSchema(introspectResponse.data)