Skip to content

Instantly share code, notes, and snippets.

@karx
Created March 21, 2023 19:37
Show Gist options
  • Save karx/72be03741fd5f0b2b41c7ae42def533a to your computer and use it in GitHub Desktop.
Save karx/72be03741fd5f0b2b41c7ae42def533a to your computer and use it in GitHub Desktop.
Request callback to async
const request = require('request')
// Convert a function with callback(in this case `request`) to async function.
module.exports = async (value) =>
new Promise((resolve, reject) => {
request(value, (error, response, data) => {
if(error) reject(error)
else resolve(data)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment