NikolayBezay

Untitled

May 18th, 2021
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. const request = require('request');
  2.  
  3. /**
  4. * Responds to any HTTP request.
  5. *
  6. * @param {!express:Request} req HTTP request context.
  7. * @param {!express:Response} res HTTP response context.
  8. */
  9. exports.Support_chef_lavan_integration = (req, res) => {
  10.  
  11. const userEmail = req.query.email;
  12.  
  13. if (!userEmail) {
  14. return res.send('email is required');
  15. }
  16.  
  17. const ACTION_URL = 'https://mcgxyy9fs-qckx1drx87pkdskcfq.auth.marketingcloudapis.com/';
  18. const configurationJson = {
  19. "grant_type": "client_credentials",
  20. "client_id": CLIENT_ID,
  21. "client_secret": CLIENT_SECRET,
  22. "scope": " data_extensions_write",
  23. "account_id": ACCOUNT_ID
  24. };
  25. /*req.query
  26. fetch(ACTION_URL, {
  27. method: 'post',
  28. body: JSON.stringify(configurationJson),
  29. headers: {
  30. 'Content-Type': 'application/json'
  31. }
  32. })
  33. .then(res => {
  34. console.log('res - ', res);
  35. res.status(200).send(res);
  36. });
  37. */
  38.  
  39. const options = {
  40. url: ACTION_URL,
  41. method: 'POST',
  42. body: JSON.stringify(configurationJson),
  43. headers: {
  44. 'Content-Type': 'application/json'
  45. }
  46. };
  47.  
  48. function callback(error, response, body) {
  49. console.log('1 - response - ', response);
  50. if (!error && response.statusCode == 200) {
  51. console.log('2 - response - ', response);
  52. }
  53. }
  54.  
  55. request(options, callback);
  56. };
  57.  
Advertisement
Add Comment
Please, Sign In to add comment