Note that there are some explanatory texts on larger screens.

plurals
  1. PONodeJS - How to Download file via Request?
    primarykey
    data
    text
    <p>I have a ExternalServe (running on Localhost) When I using Browser to request:</p> <blockquote> <p>localhost:2013/ExternalServer/getfilebyname?filename=getStatus.json</p> </blockquote> <p>Then browser downloaded getStatus.json to Download Folder.</p> <p>In my NodeJS project, I want to download getStatus.json file and I made:</p> <p>download.js</p> <pre><code>var http = require('http'); var fs = require('fs'); function getFile (){ var file = fs.createWriteStream("./../lib/user.json"); var req = http.get("http://localhost:2013/ExternalServer/getfilebyname?filename=getStatus.json", function(res) { res.pipe(file); }); } getFile(); </code></pre> <p>but when i run: node download.js the system return</p> <pre><code>&lt;html&gt;&lt;head&gt;&lt;title&gt;Apache Tomcat/8.0.0-RC1 - Error report&lt;/title&gt;&lt;style&gt;&lt;!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--&gt;&lt;/style&gt; &lt;/head&gt;&lt;body&gt;&lt;h1&gt;HTTP Status 401 - &lt;/h1&gt;&lt;HR size="1" noshade="noshade"&gt;&lt;p&gt;&lt;b&gt;type&lt;/b&gt; Status report&lt;/p&gt;&lt;p&gt;&lt;b&gt;message&lt;/b&gt; &lt;u&gt;&lt;/u&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;description&lt;/b&gt; &lt;u&gt;This request requires HTTP authentication.&lt;/u&gt;&lt;/p&gt;&lt;HR size="1" noshade="noshade"&gt;&lt;h3&gt;Apache Tomcat/8.0.0-RC1&lt;/h3&gt;&lt;/body&gt;&lt;/html&gt; </code></pre> <p>How to fix it?</p> <p>Best regard</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload