Razvan
09/26/2020, 3:39 PMval codeField = FormField.required("code")
val pageForm = Body
.webForm(Validator.Strict, codeField)
.toLens()
val validForm = pageForm(request)
val code = codeField(validForm)
but when I call the api from a static JS fetch request I get a 500 error:
org.http4k.lens.LensFailure: header 'content-type' is not acceptable
for the last line of code.
Why does it check the content-type header if it's a Body lens ? And how to get around with it ?
the JS fetch request is:
fetch{"/check", {
method: "post",
body: "code=XXXX"
})
tried with FormData and multipart got the same error.dave
09/26/2020, 3:58 PMRazvan
09/26/2020, 4:18 PMapplication/x-www-form-url-encoded
and that didn't work (lucky me to have found the one site that misspelled the content type). But removing the -
from url-encoded
fixed it.
I was using CatchAll thought it included LensFailures ones.dave
09/26/2020, 4:21 PMRazvan
09/26/2020, 4:56 PMdave
09/26/2020, 5:02 PM