Module-3-00: JavaScript Promises vs RxJS Obserables

February 14, 2023 ยท View on GitHub

DEMOS

Training

Training 1: Using Promise to fetch data from an API endpoint


Create a component that uses Promise to fetch data from an API endpoint. Write a function getData() that returns a Promise that resolves your data. Write a function handleData() that takes the resolved value from the Promise and logs it to the console. Call the getData() function and chain a .then() method to it, passing handleData as the callback function. Repeat the process and use .catch() to handle any errors. Rewrite you code using async/await.

Training 2: Using Observable to fetch data from an API endpoint


Rewrite your previous code to use Observable instead of Promise.