Skip to content

Instantly share code, notes, and snippets.

@boxabirds
Created February 15, 2020 18:26
Show Gist options
  • Save boxabirds/38e6f56cdd1bdf4bbaad697b48873fa4 to your computer and use it in GitHub Desktop.
Save boxabirds/38e6f56cdd1bdf4bbaad697b48873fa4 to your computer and use it in GitHub Desktop.
const fs = require('fs');
const path = require('path');
async function create_file_in_new_folder_with_promises() {
try {
await fsp.mkdir(path.join(__dirname, '/promise-test'));
await fsp.writeFile(
path.join(__dirname, '/promise-test', 'writeFile-promise-demo.txt'),
"Hello world from the land of promises"
);
} catch(err) {
console.log("Ugh sorry I failed even when using fancy promises. Error ${err}");
}
}
create_file_in_new_folder_with_promises();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment