-
-
Save vkarpov15/75cba89dcdcfa7f1b4726e25d889ecb4 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 fetch = require('node-fetch'); | |
// ... | |
const fetchEpic = action$ => action$.pipe( | |
filter(action => action.type === 'FETCH_STOCK_PRICE'), | |
mergeMap(async (action) => { | |
const url = `https://api.iextrading.com/1.0/stock/${action.symbol}/price`; | |
const price = await fetch(url).then(res => res.text()); | |
return Object.assign({}, action, { type: 'FETCH_STOCK_PRICE_SUCCESS', price }); | |
}), | |
catchError(err => Promise.resolve({ type: 'FETCH_STOCK_PRICE_ERROR', message: err.message })) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment