-
-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Responses of Type unit #5
Comments
We should support it in Thoth.Json(.Net) The question is how should be represents |
As a workaround, I add the following ExtraCoder: module Extra =
let unitDecoder : Decoder<unit> =fun _ _ -> () |> Ok
let unitEncoder () : JsonValue = failwith "Cannot encode unit"
let unit extra =
Extra.withCustom unitEncoder unitDecoder (defaultArg extra Extra.empty) |> Some Then I pass |
My proposed Decode/Encoder doesn't work. let! body = response.text()
return Decode.unsafeFromString decoder body body is an empty string, and Decode.unsafeFromString fails with |
My temporary fix: let! body = response.text()
let result = if body = ""
then unbox ()
else Decode.unsafeFromString decoder body
return result Same for tryFetchAs. The ExtraCoder (which is never called) is still needed. |
@MangelMaxime |
And similar fix added also to Thoth.Json.Net. |
For example, I usually return just the response code on DELETE requests.
Fetch.delete<Data,unit>
fails because there is no Auto decoder for unit.Same for
PATCH
,POST
andPUT
. It might even make sense forGET
, if the request just triggers a side effect, is used as RPC.Proposals
The text was updated successfully, but these errors were encountered: