I'm interacting my deployd server app over HTTP.
I am adding to an array using $push.
Is there a way to get the value pushed to the array?
Example:
PUT /upvotes/foo
{
"stories" : {"$push": "bar"}
}
On Put Script:
var pushedElement = ??? // I should be able to get "bar"
Thanks in advance.
Yes you can access it in the request's body.
The body is stored inside the context object - ctx
. Try this in your put script event,
var pushedElement = ctx.body.stories.$push
From deployd's docs,
ctx.body
{Object}
: The body of the request if sent as application/json or application/x-www-form-urlencoded.