Here is my code snippet
var express = require('express'); var usergrid = require('usergrid'); var config = require('./config'); var apigee = require('apigee-access'); var http = require('http'); var app = express(); app.post('/', function(req, res) { console.log("inside post"); if (!req.is('json')) { res.jsonp(400, { error : 'Invalid Request payload Type. Please make sure Content-Type header is JSON' }); return; } console.log("request: "+req); var b; try { console.log("retrieving req body"); b = req.body; console.log("retrieving req body done"); } ... Trace Record: stdout svr.358 retrieving req body done stdout svr.358 retrieving req body stdout svr.358 request: [object Object] stdout svr.358 inside post
Solved! Go to Solution.
If you're trying to access flow variables:
var flowVar = apigee.getVariable(req, 'flowVariableName');
Hi Karthick
that does not look like an error to me.
In JavaScript, when you implicitly convert an object to a string , you will get "[object Object]". It's coming from the line where you try to print out the request. (I guess you knew that). So the behavior you report is correct, and expected.
But I guess that console.log() call is an attempt to diagnose or debug some other problem.
What problem are you REALLY trying to solve?
Also, you mentioned something about a "flow variable" but I don't see any attempt to access flow variables in your code.
Hi Dino,
Thanks for that. I was not aware of this - you will get "[object Object]".
I could sort out the flow variable problem. I am trying to access the variable that gets created through a OAuth policy(Validate) but I am trying to access that through a service callout and hence the problem.
-Karthick.
console.log("request: "+JSON.stringify(req));
If you're trying to access flow variables:
var flowVar = apigee.getVariable(req, 'flowVariableName');