Skip to content

Instantly share code, notes, and snippets.

@josemunozr
Created May 2, 2020 03:12
Show Gist options
  • Save josemunozr/17cda786bbafbcb90723f165a6a63678 to your computer and use it in GitHub Desktop.
Save josemunozr/17cda786bbafbcb90723f165a6a63678 to your computer and use it in GitHub Desktop.
config async/await .babelrc and userEfect() react
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"esmodules": true
}
}
],
"@babel/preset-react"
]
}
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