nervous-systems / kvlt

Multi-target Clojure/script HTTP client
The Unlicense
69 stars 8 forks source link

Add json flag to req->node #21

Closed Baspar closed 7 years ago

Baspar commented 7 years ago

To provide a json as the body of a POST request on Node JS, Request library need to be passed the flag json to true.

Also given the number of different parameter that can be passed to the Reaquest library, don't you think it might be usefull to use req as a reference point ?

moea commented 7 years ago

@Baspar There's currently two equivalent ways to POST json:

Using metadata on :body:

(kvlt/request! {:url ... :method :post :body ^:kvlt.body/json {:a 1 :b 2}}})

explicitly passing the type:

(kvlt/request! {:url ... :method :post :type :json :form {:a 1 :b 2})

What does request's json property do differently than the above two? In general, my concern is to try and keep the Clojure and Clojurescript implementations as symmetric as possible.

Baspar commented 7 years ago

Thanks for your answer ! Passing the type is perfectly working, but it seems that MetaData solution doesn't solve the problem in Node No ned for this PR then