Created
July 11, 2017 17:49
-
-
Save nomoney4me/347375e6bc0011f7118d3709424882ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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