Hosted targets Apigee - How to retrieve query params in index.js

kumarraj764
Participant II

Hi,

I am using hosted targets in Apigee and I am not able extract query params in index.js.

Have tried as below but no luck,

Anyone has idea on how to retrieve? Please help

var http = require('http');
var AWS=require('aws-sdk');
var AmazonCognitoIdentity=require('amazon-cognito-identity-js-node');
var jwt = require('jsonwebtoken');
var apigee = require('apigee-access');
var express = require('express');

console.log('node.js application starting...');
console.log(process.env);
var app = express();

var svr = http.createServer(function(req, resp) {

UserPoolId:apigee.getVariable(req, 'UserPoolId'),
ClientId:apigee.getVariable(req, 'ClientId'),

});

app.listen(3000, function () {
console.log('GDPR C&P Distribution Point: Apigee-Node app listening on port 3000!');
});

1 2 202
2 REPLIES 2

Hi Kumar,

It is possible to get query parameters in Hosted Targets; however, we do not support the "apigee-access" module. If you would like to mimic the apigee-access functionality, please take a look at the "Is it possible to work around the lack of apigee-access?" in our FAQs

But If I understand your question right, this is an example hosted target app that can retrieve query params:

const express = require('express');
const app = express();


console.log('node.js application starting...');
console.log(process.env);


app.get('/hello', function(req, res) {
    console.log(req.query);
    res.send("hello world");
});


app.listen(process.env.PORT || 3000, function() {
  console.log('Node HTTP server is listening');
});

Thanks Kyle . I will try like you have mentioned and let you know..