Advertisement
Guest User

Untitled

a guest
Jul 10th, 2019
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. router.post('/wrikeWebhooks', async function(req, res, next) {
  2. console.log('Running POST /wrikeWebhooks ');
  3. console.log('req.body[0] is ', req.body[0]);
  4. console.log('running res.sendStatus(200)');
  5.  
  6. res.sendStatus(200) // <-- If we don't send status 200, the webhook will send up to 3 duplicate objects, and then go into suspended status
  7.  
  8. const newWrikeTaskID = req.body[0].taskId;
  9. console.log('newWrikeTaskID -- ', newWrikeTaskID);
  10.  
  11. await parseWrikeTaskForKeyword(newWrikeTaskID);
  12. })
  13.  
  14.  
  15. async function parseWrikeTaskForKeyword(wrikeTaskTaskID) {
  16. try {
  17. const response1 = await axios.get('https://www.wrike.com/api/v4/tasks/'+ wrikeTaskTaskID +'/?access_token=' + envConfig.WRIKE_perm_token);
  18. const wrikeTaskTitle = response1.data.data[0].title;
  19.  
  20. const wrikeMarketoTaskCreationKeyword = 'MarketoWrikeTask';
  21. console.log('wrikeTaskTitle.includes(wrikeMarketoTaskCreationKeyword) ? -->', wrikeTaskTitle.includes(wrikeMarketoTaskCreationKeyword))
  22.  
  23. // Next, take response1.data.data[0] object and parse it's description property...
  24. // But that will be a function that fires within a task queue.
  25. } catch (e) {
  26. // console.error('error: ', e);
  27. // }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement