parameter is not of type 'Blob' <p>I have written the code below to display the text from a local file using the file API but when I click the button, nothing happens and I get the following error when I inspect the element in the browser, what am I dong wrong?</p> <blockquote> <p>Uncaught TypeError: Failed to execute 'readAsText' on 'FileReader': parameter 1 is not of type 'Blob'.</p> </blockquote> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;body&gt; &lt;p&gt;This example uses the addEventListener() method to attach a click event to a button.&lt;/p&gt; &lt;button id="myBtn"&gt;Try it&lt;/button&gt; &lt;pre id="file"&gt;&lt;/pre&gt; &lt;script&gt; document.getElementById("myBtn").addEventListener("click", function(){ var file = "test.txt" var reader = new FileReader(); document.getElementById('file').innerText = reader.result; reader.readAsText(file); }); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p>