Guest User

Untitled

a guest
May 25th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. const promiseApproach = (url) => {
  2. let result;
  3. fetch(url)
  4. .then((response) => {
  5. result = response;
  6. })
  7. .catch(() => {
  8. // whatever
  9. });
  10. return result;
  11. };
  12.  
  13. const awaitApproach = async (url) => {
  14. try {
  15. const result = await fetch(url);
  16. return result;
  17. } catch (error) {
  18. throw error;
  19. }
  20. };
Add Comment
Please, Sign In to add comment