Skip to content

Instantly share code, notes, and snippets.

@Den1al
Created April 20, 2019 11:20
Show Gist options
  • Select an option

  • Save Den1al/a35cc5aad4b4beaea5d6ac7b69adf3fe to your computer and use it in GitHub Desktop.

Select an option

Save Den1al/a35cc5aad4b4beaea5d6ac7b69adf3fe to your computer and use it in GitHub Desktop.
converting the old callback based DNS lookup in NodeJS to modern Async function
import { lookup } from 'dns';
export default async function(name) {
return new Promise((resolve, reject) => {
lookup(name, (err, ips) => {
if (err) {
reject(err);
} else {
resolve(ips);
}
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment