Created
June 30, 2020 08:43
-
-
Save paulmwatson/128fe8b77ce4b7f4a695920b3f308bb5 to your computer and use it in GitHub Desktop.
Example of using async and await in a Vercel serverless function
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
const unravel = async (url) => { | |
const response = await fetch(url) | |
return response | |
} | |
export default async (req, res) => { | |
const response = await unravel(req.query.url) | |
res.statusCode = 200 | |
res.setHeader('Content-Type', 'application/json') | |
res.end(JSON.stringify({ response: response })) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment