Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

122
Vistas
How to get status code of successful response in handler in cljs-ajax?

I am successfully getting a response from an endpoint using cljs-ajax (as shown below). However, I cannot seem to differentiate between different success status codes in my response handler.

(ns mynamespace
  (:require [ajax.core :as ajax]))

(defn start-monitoring []
  (let [handler (fn [[ok response]]
                  (if ok
                    (.log js/console response)
                    (.error js/console (str response))))]
    (ajax/ajax-request {:uri "/myendpoint"
                   :method :get
                   :params {:since (.getTime (js/Date.))}
                   :handler handler
                   :format (ajax/json-request-format)
                   :response-format (ajax/json-response-format {:keywords? true})})))

"ok" in the handler appears to simply be a true/false success flag, and does not differentiate between 200 and 204 status codes, both of which are considered successes. The response body is whatever text is returned in the response, and doesn't appear to contain a status code, unless the request failed.

How can I determine the status code of the response?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Seems like the response is a map with keys like :status which contains 200 for my test. The rest of the keys are: (:status :failure :response :status-text :original-text)

over 4 years ago · Santiago Trujillo Denunciar

0

Use :response-format (ajax/ring-response-format). See also: https://github.com/JulianBirch/cljs-ajax/issues/57

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda