Skip to content

Instantly share code, notes, and snippets.

@artiya4u
Created March 8, 2020 18:36
Show Gist options
  • Save artiya4u/26a56a17252ea7abe5a8d8475a08ffe9 to your computer and use it in GitHub Desktop.
Save artiya4u/26a56a17252ea7abe5a8d8475a08ffe9 to your computer and use it in GitHub Desktop.
SyntaxError: await is only valid in async function
const {promisify} = require('util');
const fs = require('fs');
const readFileAsync = promisify(fs.readFile);
const filePath = 'index.js';
let text = await readFileAsync(filePath, {encoding: 'utf8'});
console.log(text);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment