Skip to content

Instantly share code, notes, and snippets.

@likr
Created June 14, 2020 15:06
Show Gist options
  • Save likr/70b0a59ddcc45c562dc5dc3791b7791f to your computer and use it in GitHub Desktop.
Save likr/70b0a59ddcc45c562dc5dc3791b7791f to your computer and use it in GitHub Desktop.
const getImageUrl = async () => {
const response1 = await fetch('https://example.com');
const data1 = await response1.json();
const response2 = await fetch(data1.url);
const data2 = await response2.json();
return data2
};
const App = () => {
const [data, setData] = useState(null);
useEffect(() => {
getImageUrl().then((data) => {
setData(data);
});
}, []);
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment