Tuesday, 18 April 2017

Node wrapper API for a different Download API

I am trying to write a wrapper API for a different API which takes filename as input and downloads the file.

The raw api is https://test.com/?filename=abc.pdf

I want to write a wrapper for this above API, but that doesn't seems to be working, it just prints some data which I cant read but doesnot send the file.

  var options = {
    "method": "GET",
    "hostname": test.com,
    "port": 443,
    "path": "/?filename=" +fileName,
    "rejectUnauthorized": false,
  }

apiHelper.makeRequest(https, options, false, function(responseObject){
    if(responseObject.error){
      downloadBackupCallback(null, responseObject.error);
    }
    else{
      downloadBackupCallback(responseObject.data, null);
    }
  })

Can any one please help me here.



via JK_Jha

No comments:

Post a Comment