Created
June 14, 2020 15:06
-
-
Save likr/70b0a59ddcc45c562dc5dc3791b7791f to your computer and use it in GitHub Desktop.
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
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