Closed deadghost closed 7 years ago
We're using the definition of success provided by cljs-ajax. I can't see anything obviously wrong with the code above, what is it actually returning in the HTTP request?
Status Code: 200 OK
Response Headers
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://mysite.dev
Connection: keep-alive
Content-Length: 0
-------------------------------------------
Status Code: 201 CREATED
Response Headers
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://mysite.dev
Connection: keep-alive
Content-Length: 0
:on-failure
handler gets triggered. https://httpbin.org/post works fine; sends a json body instead of empty. I'd guess there are some :body
requirements lurking.
Sure, what does Chrome Devtools show about the requests? What is the error being returned in the :on-failure?
{:response nil, :last-method "POST", :original-text "", :last-error "", :failure :parse, :status-text "Invalid JSON string: Format should have been JSON", :status 201, :uri "https://httpbin.org/status/201", :debug-message "No Error", :last-error-code 0}
Looks like it can't take an empty body. I don't know if I quite agree an empty body should count as a failure but I'll consider this issue resolved.
I don't know if I quite agree an empty body should count as a failure
Ok sure. You can raise an issue with cljs-ajax about it if you'd like, as they make the decision about success/failure.
Some situations where I'd expect success but receive failure:
Seems like just a 200 or 201 response is not enough to be considered a success.