I have a DELETE endpoint that returns a success status code of 204. I've been getting a "null body" error and have tried using try catch and if else to catch the error, but they aren't working. Removing ctx.json(null) for 204 codes fixes the problem. Here's the error I've been getting with my DELETE 204:
createRequestListener.ts:56 Uncaught (in promise) TypeError: Failed to construct 'Response': Response with null body status cannot have body
at Object.onMockedResponse (createRequestListener.ts:56:38)
at handleRequest (handleRequest.ts:127:3)
at async createRequestListener.ts:34:7
I have a DELETE endpoint that returns a success status code of 204. I've been getting a "null body" error and have tried using
try catch
andif else
to catch the error, but they aren't working. Removingctx.json(null)
for 204 codes fixes the problem. Here's the error I've been getting with my DELETE 204: