JavaScript Socket hang up when using axios.get, but not when using https.get

To the best of my knowledge, I am doing the same thing using 2 different approaches:

const https = require("https");
const axios = require("axios");

let httpsAgent = new https.Agent({rejectUnauthorized: false});

axios.get(`https://${hostname}:${port}${path}`, {httpsAgent})
    .then((data) => { console.log("axios success: " + data.substr(0, 100)); })
    .catch((error) => { console.log("axios error: " + error); });

let data = "";
https.get({ hostname, path, port, agent: httpsAgent },
    (response) => {
        response.on("data", (chunk) => { data += chunk; });
        response.on("end", () => { console.log("https success: " + data.substr(0, 100)); });
    })
    .on("error", (error) => { console.log("https error: " + error); });

When I run this code, i get 2 different outcomes:

PS C:\Users\me> .\node\node.exe .\generate-test-data.js
axios error: Error: socket hang up
https success: [{"cool":"data"...

What is going on here? I have a feeling it has to do with asynchronicity, but not quite sure how... Can somebody give me a hint as to how/why these 2 behaviors are different?

Answer:1

I am new to EXTJS. Now im trying to develop simple pivot grid example. my code is: Ext.onReady(function () { var myStore = new Ext.data.ArrayStore({ autoLoad: true, fields: ['gender', ...

I am new to EXTJS. Now im trying to develop simple pivot grid example. my code is: Ext.onReady(function () { var myStore = new Ext.data.ArrayStore({ autoLoad: true, fields: ['gender', ...

  1. extjs pivot grid example
  2. extjs pivot grid
  3. extjs pivot grid fiddle
  4. extjs pivot grid demo
  5. extjs pivot grid kitchen sink
  6. extjs pivot grid store
  7. extjs pivot grid export
  8. extjs 6 pivot grid example
  9. extjs 6 pivot grid
  10. extjs 4 pivot grid example
  11. extjs 6.2 pivot grid
  12. extjs pivotgrid leftaxis

I'm trying to hide a div when the user clicks anywhere outside of the div with id "main". I am using vanilla Javascript and would prefer not to use jQuery. The code I have works well but whenever ...

I'm trying to hide a div when the user clicks anywhere outside of the div with id "main". I am using vanilla Javascript and would prefer not to use jQuery. The code I have works well but whenever ...

  1. hiding elements with javascript
  2. hiding div with javascript
  3. hiding javascript code
  4. hiding javascript
  5. hiding javascript source code
  6. hiding javascript from view source
  7. hiding javascript in image
  8. hiding javascript code view source
  9. hiding javascript in html
  10. hiding javascript from incompatible browsers
  11. hiding javascript from old browsers
  12. hiding html elements with javascript
  13. hiding a button with javascript
  14. hiding a href with javascript

I'm at a complete loss here. I'll provide what I currently have below, but for some reason, every iteration I try, something goes wrong...either the animation of scroll doesn't work but the other ...

I'm at a complete loss here. I'll provide what I currently have below, but for some reason, every iteration I try, something goes wrong...either the animation of scroll doesn't work but the other ...

Hi i have a link tag that i am creating from javascript. now i want to append a parameters to that link just like below example.so that when the user clicks that button it should go to that url along ...

Hi i have a link tag that i am creating from javascript. now i want to append a parameters to that link just like below example.so that when the user clicks that button it should go to that url along ...

  1. creating link with hyperlink
  2. creating link in html
  3. creating link in linux
  4. creating link in excel
  5. creating link in word
  6. creating link in unix
  7. creating link in word document
  8. creating link in instagram bio
  9. creating link in pdf
  10. creating link to folder
  11. creating link in ubuntu
  12. creating link to pdf file
  13. creating link in windows
  14. creating link in markdown
  15. creating link in excel sheet
  16. creating link in instagram post
  17. creating link in dropbox
  18. creating link in pdf document
  19. creating link in php
  20. creating link in html without underline