AjaxService.js 1011 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. *+------------------------------------------------------------------------+
  3. *| Licensed Materials - Property of IBM
  4. *| IBM Cognos Products: Content Explorer
  5. *| (C) Copyright IBM Corp. 2015, 2018
  6. *|
  7. *| US Government Users Restricted Rights - Use, duplication or disclosure
  8. *| restricted by GSA ADP Schedule Contract with IBM Corp.
  9. *+------------------------------------------------------------------------+
  10. */
  11. export default class AjaxService {
  12. constructor(options) {
  13. this.ajaxService = options.glassContext.getCoreSvc('.Ajax');
  14. }
  15. getData = (url, data) => {
  16. const options = {
  17. type: 'GET',
  18. url: url,
  19. data: data,
  20. dataType: 'json'
  21. };
  22. return this.doAjax(options);
  23. }
  24. postData = (url, data) => {
  25. const options = {
  26. type: 'POST',
  27. headers: {
  28. 'Accept': 'application/json',
  29. 'Content-Type': 'application/json'
  30. },
  31. url: url,
  32. data: JSON.stringify(data)
  33. };
  34. return this.doAjax(options);
  35. }
  36. doAjax = (options) => {
  37. return this.ajaxService.ajax(options);
  38. }
  39. }