1

I'm using the following in rails to push to node.js:

NodePush[].trigger('unit', 'join', {:id =>record.user_id, :name => record.user.name}, record.unit_id)

Problem I'm having is console is logging the results as:

{"id":7154,"name":"Medallions"}

What I want is for the console to output an object like so:

Object
 id: 7154
 name: "Medallions"

Any suggestions on how to update the rails code to create an object? Thanks

1 Answer 1

1

When you push data from Rails to Node, you're pushing JSON. If you want to see the JavaScript object that Node reconstitutes on its end, you need to log the object after it's parsed, or alternately, explicitly call JSON.parse(str) when you log the object to the console (where str is the JSON string).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.