node-onesignal icon indicating copy to clipboard operation
node-onesignal copied to clipboard

TypeError: apickli.Apickli is not a constructor

Open SanjayBhandari515 opened this issue 8 years ago • 0 comments

Hi,

I am getting error : TypeError: apickli.Apickli is not a constructor when i am trying to use Sendpostrequest .js again in my next step in a scenario. Below is the code i am using. From A.js i am trying to call Sendpostrequest for first step its working fine but when i am using it again i am getting error TypeError: apickli.Apickli is not a constructor

A.js Sendpostrequest(obj.domain, obj.requestheader, querystring.stringify(obj.requestbody))

Sendpostrequest .js

'use strict'; const querystring = require('querystring'); let apickli = require('apickli');

const Sendpostrequest = (requesturl, header,body)=>{ apickli = new apickli.Apickli('https', requesturl); for(let key in header) { apickli.addRequestHeader(key,header[key]); }

console.log("Header ------------->>>>>>>>>>>", header); console.log("Url------------->>>>>>>>",requesturl); //console.log("1 test >>>>>>>>>", header); if(body){ apickli.setRequestBody(body); } return new Promise((resolve,reject)=>{ apickli.post('',function(error, response) { if (error) { return reject(error); }

        return resolve(response);
    });
})

} module.exports = Sendpostrequest;

SanjayBhandari515 avatar Apr 23 '18 11:04 SanjayBhandari515