1

i have a function i am trying to read a file from the same directory it is showing promise pending what needs to be fixed here

index.js

const fs = require('fs').promises;
const path = require('path');
const filePath = path.join(__dirname, 'Accounts.txt');
async function ReadFile() {   
  try {
    let data = await fs.readFile(path.join(filePath));
    data = String(data)
    return data;
 } catch(e) {
   console.log(e);
 } 

Console

READING FILE>>>> Promise { <pending> }
[0] (node:6379) ExperimentalWarning: The fs.promises API is experimental
hussain
  • 6,587
  • 18
  • 79
  • 152

0 Answers0