Hot to send ajax request with cljs-ajax with its body keys without colons

Hot to send ajax request with cljs-ajax with its body keys without colons

我正在使用 cljs-ajax 并尝试发送 POST 请求,内容如下:

(POST "http://example.com/some/endpoint"
      {:body {:username "me"
              :password "pass"}
      :handler some-handler
      :error-handler some-error-handler})

这会发送请求,但请求有效负载在关键字前包含冒号。就像,我期待 username 被发送,而不是 :username。我尝试添加 :format :json 但它没有任何改变。

我做错了什么?

我以前从未使用过 cljs-ajax,但是如果您使用 :params 而不是 :body,阅读文档,cljs-ajax 应该将其识别为 POST请求并在正文中发送信息,如果是 GET 请求,它会将其添加为查询字符串。

:params - the parameters that will be sent with the request, format dependent: :transit and :edn can send anything, :json, :text and :raw need to be given a map. GET will add params onto the query string, POST will put the params in the body

如果第一次不起作用,请不要忘记添加那些 JSON 格式标志。

告诉我你过得怎么样。