We are trying to implement a proxy using Node.JS.
When we try to use the Node.JS “request” module, Apigee gives an error, which you can see from http://org-test.apigee.net.
The code is very simple and similar to the sample (node-samples/node/mashup/mashup.js at master · apigee/node-samples · GitHub).
var request = require(‘request’);
var http = require(‘http’);
var urlparse = require(‘url’);
var util = require(‘util’);
function sendError(resp, code, msg) {
var o = { ‘error’: msg };
resp.writeHead(code, {‘Content-Type’: ‘application/json’});
resp.end(JSON.stringify(o));
}
var svr = http.createServer(function(req, resp) {
var request = require(‘request’);
var options = {
url: ‘https://test.com/api/v2/asa’,
method:‘POST’,
headers: {
‘Accept’: ‘application/json’,
‘Accept-Charset’: ‘utf-8’,
‘Api-Key’: ‘33769302e0812dsadasdadd’
},
json:true,
body:{resource:{
group_name:‘testing’
}}
};
request.post(options, function (err,res,body) {
console.log(body)
});
resp.writeHead(200, {‘Content-Type’: ‘application/json’});
resp.end(JSON.stringify(“{}”));
});
svr.listen(9000, function() {
console.log(‘Node Mashup sample app is running on port 9000’);
});
When I deploy my application, I use the following command:
apigeetool deploynodeapp -u email -p password -o org -e test -n testapp -d . -m app.js
Can you help me with this issue, or guide me to the people that can help me resolve the issue?