Hey,

there are many ways to get the properties of a javascript object, but if you 
want to rely on advanced compilation and might miss some externs its probably 
best to use aget.

(let [name (aget req "params" "name")] ...)

But these work too

(.. req -params -name)
(-> req .-params .-name)

If you want to print an object you could do (pr-str (js->clj obj)), or use some 
of the inspect things node has (I think).

HTH,
/thomas


On Monday, March 10, 2014 9:24:18 AM UTC+1, Mark Fisher wrote:
> I've been dipping my toes in the clojurescript / node.js world and came 
> across a couple of examples using restify.
> 
> Examples are:
>  - 
> http://caffeinatedideas.com/2013/08/29/taming-nodejs-with-clojurescript.html
>  - http://dannysu.com/2013/04/14/cljs-restify-node/
> 
> Both of which use a form request/params/name to access a value on the request 
> object.
> However, I'm getting compile errors trying to use this:
> 
> clojure.lang.ExceptionInfo: failed compiling 
> file:src-node-cljs/cljs_test/greet_server.cljs {:file #<File 
> src-node-cljs/cljs_test/greet_server.cljs>}
> ...
> Caused by: clojure.lang.ExceptionInfo: Invalid token: request/params/name
> 
> What's the correct way to access the name value here?
> 
> In javascript (from first example), it's written as:
>   var name = request.params["name"];
> 
> but given my newness to clojurescript and interop, I can't find the correct 
> invocation.
> I've tried (.-params request) which when printed shows it's a [object 
> Object], but I can't work out how to get the value out of that (if it is even 
> the right thing).
> 
> Cheers,
> Mark

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to