5

I am new to node.js, I use request send the post request.but I got a error!

     request({
         method: 'POST',
         url: config.api + '/index',
         body: {
         name: "name"
        },
        json: true
      })

        throw er; // Unhandled 'error' event
        ^

         Error: Invalid protocol: 127.0.0.1:
L.LK
  • 55
  • 1
  • 5

4 Answers4

5

I write this: It work fine, you can modify it like this.

     request({
           method: 'POST',
           url: 'http://127.0.0.1:3000' + '/index',
           body: {
           name: "name"
          },
          json: true
          })
MWY
  • 1,071
  • 7
  • 15
1

Your code is incorrect: follow the instructions on the NPM module page.

skiilaa
  • 1,212
  • 11
  • 20
EduardoMaia
  • 591
  • 1
  • 4
  • 17
0

If you're using a PHP Development Server please refer to this thread for the solution. Stack Overflow

0

I met a similar issue on Win10 after a system update. It was caused by the system proxy settings.

http_proxy=127.0.0.1:8888
https_proxy=127.0.0.1:8888

Change the above environment settings to

http_proxy=http://127.0.0.1:8888
https_proxy=http://127.0.0.1:8888

done the job for me.

Btw, if you use git-bash, you can also check the git config.

$git config --list
...
http.sslverify=false
http.proxy=http://127.0.0.1:8888
https.proxy=http://127.0.0.1:8888
...
W.Perrin
  • 4,217
  • 32
  • 31