Fork me on GitHub
#pedestal
<
2017-06-21
>
jjttjj18:06:03

I'm having a hard time to get a clojurescript frontend working for the vase-component sample app. GET requests work fine, but i've tried several different ways to POST a new "pet" to the db without any luck. I can succesfully post to the DB with clj-http, for example with

(http/post ""
               {:form-params
                {:payload [{:pet-store.pet/id 101
                            :pet-store.pet/name "harry"
                            :pet-store.pet/tag "harry's tag"
                                          }]}
                :content-type :json})
But I can't seem to figure out how to make this work from clojurescript after attempting with jquery and cljs-ajax, attempting to use json and edn. Are there any examples of using vase with clojurescript?

jjttjj18:06:41

here's my attempt with cljs-ajax:

(ajax/POST ""
             :params {:payload [{:pet-store.pet/id   102
                                 :pet-store.pet/name "harry"
                                 :pet-store.pet/tag  "harry's tag"
                                 }]}
             :format :json ;(ajax-edn/edn-request-format) ;;attempt edn and json formats
             )
but it results in {whitelist [{}], transaction [[nil nil nil] [nil nil nil] [nil nil nil] [nil nil nil]]}

jjttjj18:06:23

OK I actually just got the above example working buy using string keys such as "pet-store.pet/id 102" so that should work for now. Is there something I have to do server-side to accept EDN? The docs seemed to suggest it should automatically be able to accept edn if the content type was correctly set

shaun-mahood20:06:52

@mtnygard: I'm working through the guides, and I'm having some difficulty with http://pedestal.io/guides/hello-world-content-types - specifically, how to map the 'cond->' macro portion back to the original version. I've never actually needed to use 'cond->' so I'm happy to figure out how it works, but I think it would be worth putting a more beginner friendly version in as an intermediate step - so far it's been the only real stumbling block I've found if I assume it's geared towards beginners.

shaun-mahood20:06:53

@mtnygard: I just opened an issue on the docs site - sorry, I should have done that first!

lxsameer20:06:50

hey folks, I read somewhere that extending pedestal is easy because everything are protocols , right ? i yes, can you give me an quick example

shaun-mahood22:06:11

Is there any guidance on when to syntax quote interceptors? Tutorials all go without it, but the lein template uses it.