I am getting some strange behavior with the typescript client as follows:
My Service does this:
return new HttpResult() { StatusCode = System.Net.HttpStatusCode.OK };
With a method return type of object and the DTO interface is IReturnVoid (I’ve tried different options there…)
Typescript client gets this:
ERROR Error: Uncaught (in promise): SyntaxError: Unexpected end of JSON input
SyntaxError: Unexpected end of JSON input
at JsonServiceClient.push…/node_modules/@servicestack/client/dist/index.js.JsonServiceClient.createResponse (index.js:748)
Which when looking at the source it looks like the service is setting headers as if its returning JSON which it is not and that is confusing the client
Looking for advice on how to properly implement server and client side when all you return is a status code.
200 OK is the default so you shouldn’t need to return anything. If your Service is IReturnVoid your method signature should be void or your Service should return null.
Although if your Service doesn’t have a response ServiceStack will return a 204 No Content which is preferred, but you can leave it as a 200 OK Response by overriding Config.Return204NoContentForEmptyResponse = false.