Created
February 19, 2022 21:43
-
-
Save johnpolacek/b6d85286a96b4ff14efc07cf040a66d8 to your computer and use it in GitHub Desktop.
Fetch Example
This file contains hidden or 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
fetch('https://example.com').then(response => { | |
if (!response.ok) { | |
throw Error(response.statusText); | |
} | |
return response.json(); | |
}) | |
.then(data => { | |
res.status(200).json({ data }) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment