Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- router.post('/wrikeWebhooks', async function(req, res, next) {
- console.log('Running POST /wrikeWebhooks ');
- console.log('req.body[0] is ', req.body[0]);
- console.log('running res.sendStatus(200)');
- 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
- const newWrikeTaskID = req.body[0].taskId;
- console.log('newWrikeTaskID -- ', newWrikeTaskID);
- await parseWrikeTaskForKeyword(newWrikeTaskID);
- })
- async function parseWrikeTaskForKeyword(wrikeTaskTaskID) {
- try {
- const response1 = await axios.get('https://www.wrike.com/api/v4/tasks/'+ wrikeTaskTaskID +'/?access_token=' + envConfig.WRIKE_perm_token);
- const wrikeTaskTitle = response1.data.data[0].title;
- const wrikeMarketoTaskCreationKeyword = 'MarketoWrikeTask';
- console.log('wrikeTaskTitle.includes(wrikeMarketoTaskCreationKeyword) ? -->', wrikeTaskTitle.includes(wrikeMarketoTaskCreationKeyword))
- // Next, take response1.data.data[0] object and parse it's description property...
- // But that will be a function that fires within a task queue.
- } catch (e) {
- // console.error('error: ', e);
- // }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement