Skip to content

Instantly share code, notes, and snippets.

@paulmwatson
Created June 30, 2020 08:43
Show Gist options
  • Save paulmwatson/128fe8b77ce4b7f4a695920b3f308bb5 to your computer and use it in GitHub Desktop.
Save paulmwatson/128fe8b77ce4b7f4a695920b3f308bb5 to your computer and use it in GitHub Desktop.
Example of using async and await in a Vercel serverless function
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