diff --git a/src/protocols/Http.ts b/src/protocols/Http.ts index bcc86fed6..ab7d2c98e 100644 --- a/src/protocols/Http.ts +++ b/src/protocols/Http.ts @@ -1,9 +1,9 @@ "use strict"; -import staticHttpRoutes from "./routes.json"; -import { KuzzleAbstractProtocol } from "./abstract/Base"; import { HttpRoutes, JSONObject } from "../types"; import { RequestPayload } from "../types/RequestPayload"; +import { KuzzleAbstractProtocol } from "./abstract/Base"; +import staticHttpRoutes from "./routes.json"; /** * Http protocol used to connect to a Kuzzle server. @@ -405,6 +405,10 @@ export default class HttpProtocol extends KuzzleAbstractProtocol { ); } + if (response.body === "") { + return ""; + } + return JSON.parse(response.body); }); } @@ -435,6 +439,10 @@ export default class HttpProtocol extends KuzzleAbstractProtocol { xhr.onload = () => { try { + if (xhr.responseText === "") { + resolve(""); + } + const json = JSON.parse(xhr.responseText); resolve(json); } catch (err) {