Created
March 21, 2023 19:37
-
-
Save karx/72be03741fd5f0b2b41c7ae42def533a to your computer and use it in GitHub Desktop.
Request callback to async
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 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