I have an OpenWhisk action that returns a response object, because I want to be able to control the headers and HTTP status code. My action returns something like this:
return {
statusCode: 200,
headers: { 'Content-Type': 'application/json' },
body: { x: 1 }
};
I deploy the action in a package from the command-line with:
wsk action update myproj/myaction --kind nodejs:6 myaction.zip --web true
And expose it as API on IBM Cloud Functions with:
wsk api create /myproj /myaction get myproj/myaction
But when I visit the API call with curl
, I get the whole response object, not just the data:
curl '.../myproj/myaction'
{
"statusCode": 200,
"headers": {
"Content-Type": "application/json"
},
"body": { x: 1 }
}
I was expecting to get just { x: 1 }
.
What do I need to do to fix this?