LjHttpHelper.js 924 B

1234567891011121314151617181920212223242526272829303132333435
  1. var request = require('request');
  2. var cryptoJS = require("crypto-js");
  3. var logHelper = require("./LjLogHelper");
  4. /**
  5. * The helper of http
  6. */
  7. class LjHttpHelper
  8. {
  9. static request(optinons,callback)
  10. {
  11. //签名
  12. const signStr = 'path='+optinons.url+'&uid='+optinons.uid+'&eid='+optinons.eid+'&'+optinons.token;
  13. const sign = cryptoJS.MD5(signStr).toString();
  14. logHelper.info(optinons);
  15. let headers = {
  16. 'Content-Type':'application/json',
  17. 'eid':optinons.eid,
  18. 'uid':optinons.uid,
  19. 'sign':sign,
  20. 'terminal':"web",
  21. 'merchant':"angelbell",
  22. 'requestId':"11111111111111",
  23. };
  24. let optionsObj = {};
  25. optionsObj.url = optinons.url;
  26. optionsObj.headers = headers;
  27. logHelper.info(optionsObj);
  28. request(optionsObj, callback);
  29. }
  30. }
  31. module.exports = LjHttpHelper;