mockaton 13.0.0 → 13.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "mockaton",
3
3
  "description": "HTTP Mock Server",
4
4
  "type": "module",
5
- "version": "13.0.0",
5
+ "version": "13.0.1",
6
6
  "exports": {
7
7
  ".": {
8
8
  "import": "./index.js",
@@ -99,7 +99,11 @@ async function updatePayloadViewer(proxied, file, response) {
99
99
  ? PayloadViewerTitleWhenProxied(response)
100
100
  : PayloadViewerTitle(file, response.statusText))
101
101
 
102
- // All branches naively assume GET 200
102
+ if (!response.ok) {
103
+ codeRef.elem.textContent = await bodyAsText()
104
+ return
105
+ }
106
+
103
107
  if (mime.startsWith('image/'))
104
108
  codeRef.elem.replaceChildren(r('img', {
105
109
  src: URL.createObjectURL(await response.blob())
@@ -138,8 +142,8 @@ async function updatePayloadViewer(proxied, file, response) {
138
142
  }, t`Download`))
139
143
 
140
144
 
141
- function bodyAsText() {
142
- return response.text() || t`/* Empty Response Body */`
145
+ async function bodyAsText() {
146
+ return (await response.text()) || t`/* Empty Response Body */`
143
147
  }
144
148
  }
145
149