title: how to return the value obtained from fs.readFile in node js?
body: <p>How to possibly, return the data obtained from fread to fwrite callee? Even if I return it, it states the error as &quot;The &quot;data&quot; argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received an instance of Promise&quot; :/</p>
  <p>Neither data.then() doesn't works, says data.then() isn't a function</p>
  <pre><code>const fs=require(&quot;fs&quot;).promises;
  const path=require(&quot;path&quot;);
  
  async function fread(fn)
  {
      try {
          let data=await fs.readFile(path.join(__dirname,fn),&quot;utf-8&quot;)
          return data.data; ***//issue***
          
      } catch (error) {
          console.error(error.message)
      }
  }
  
  async function fwrite(from,to)
  {
      try {
          const data=fread(from)
       
          await fs.writeFile(path.join(__dirname,to),data)
         
  
  
      } catch (error) {
          console.error(error.message)
      }
  }
  
  async function fappend(to,data)
  {
      try {
          await fs.appendFile(path(__dirname))
  
  
      } catch (error) {
          console.error(error.message)
      }
  
  
  }
  
  
  
  
  
  module.exports={fread,fwrite};
  </code></pre>