Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const promiseApproach = (url) => {
- let result;
- fetch(url)
- .then((response) => {
- result = response;
- })
- .catch(() => {
- // whatever
- });
- return result;
- };
- const awaitApproach = async (url) => {
- try {
- const result = await fetch(url);
- return result;
- } catch (error) {
- throw error;
- }
- };
Add Comment
Please, Sign In to add comment