0

I've a sails.js app which makes api request in third party (for an example marketo api) to get data.

Is there any way that I can set a proxy in sails.js so that I can see all the request made by sail.js app into the fiddler.

By the way my os is ubuntu 14.04 and I'm using mono to run fiddler

Community
  • 1
  • 1

1 Answers1

1

It depends on how you are making your API requests.

If you are using request, you can set the proxy details this way:

let request = require('request');
// using default fiddler port
let proxiedRequest = request.defaults({'proxy': 'http://127.0.0.1:8888'});

proxiedRequest.get("http://api.example.com/foo", function (err, resp, body) {
  ...
})

If you are using the node http client, check "How can I use an http proxy with node.js http.Client?"

Community
  • 1
  • 1
gnuns
  • 596
  • 5
  • 12
  • @gnus Actually I've no control on how the request has been made because I use third party library for multiple vendor. suppose for marketo I use https://www.npmjs.com/package/node-marketo-rest so it may vary from library to library. So, I need generic solution which will work regardless how those libraries interact with third party. – MD. Jahidul Islam Feb 10 '17 at 03:46