Skip to content

Instantly share code, notes, and snippets.

@nomoney4me
Created July 11, 2017 17:49
Show Gist options
  • Save nomoney4me/347375e6bc0011f7118d3709424882ac to your computer and use it in GitHub Desktop.
Save nomoney4me/347375e6bc0011f7118d3709424882ac to your computer and use it in GitHub Desktop.
app.get('/conflictMatrix', (req, res) => {
var token = Promise.try(() => {
return tokenPromise()
})
var courses = knex('offered_courses').select('*').where('NumSections','<',3).andWhere('Offered', 1).map((row) => {
row.conflicts = {};
return row
}).then(rows => rows);
Promise.all([courses, token]).then((values) => {
var newCourseList = courses.reduce((newArray, course) => {
var url = process.env.url;
fetch(url, {headers:
{'Cookie':'t='+token.Token}
}).then(results => results.json()).then((conflicts) => {
return course.conflicts = conflicts
})
return newArray
}, [])
console.log(newCourseList)
res.json(newCourseList)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment