Created
June 11, 2018 15:13
-
-
Save w3cj/7b07fde8803af6857f6a3e725d8b01af to your computer and use it in GitHub Desktop.
This file contains hidden or 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('/search/:location/:job', (request, response) => { | |
const { location, job } = request.params; | |
const cl = `https://${location}.craigslist.org/search/jjj?query=${job}`; | |
const reddit = `https://www.reddit.com/r/jobbit/search.json?q=${job}&restrict_sr=1`; | |
Promise.all([ | |
fetch(cl) | |
.then(response => response.text()), | |
fetch(reddit) | |
.then(res => res.json()) | |
]).then(results => { // results is an array with the results of both fetch calls | |
const body = results[0]; | |
const clJson = craigslistGet(body); | |
const redditJson = results[1]; | |
response.json({ | |
redditJson, | |
clJson | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment