Created
May 2, 2020 03:12
-
-
Save josemunozr/17cda786bbafbcb90723f165a6a63678 to your computer and use it in GitHub Desktop.
config async/await .babelrc and userEfect() react
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
Show hidden characters
{ | |
"presets": [ | |
[ | |
"@babel/preset-env", | |
{ | |
"targets": { | |
"esmodules": true | |
} | |
} | |
], | |
"@babel/preset-react" | |
] | |
} |
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
useEffect(() => { | |
const foo = async () => { | |
try { | |
const response = await fetch("API"); | |
const data = await response.json(); | |
return setData(data); | |
} catch { | |
console.log(error); | |
} | |
}; | |
foo(); | |
}, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment