Created
February 4, 2018 13:42
-
-
Save dpalita/24272bd9f938767dbaf61b7adb10303a 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
const fetchNews = (subject: string): Promise<News[]> => { | |
return fetch('http://newsApi?subject=' + subject) | |
// promise | |
.then(res => res.text() /* re promise ^^ */) | |
} | |
const trumpNews = fetchNews('Trump') | |
const kimNews = fetchNews('Kim Jong-Un') | |
trumpNews.then(news => readNewsAndLaugh(news)) | |
kimNews.then(news => readNewsAndLaugh(news)) | |
Promise.all(trumpNews, kimNews) | |
.then(newsArray => readNewsAndCry(flatten(newsArray))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment