Q:

Electron Net module return no event

I would like use net module in main process Electron, but after new net.request(arg);, i've no events : no response, no error ...
const arg = {
  method: 'get',
  headers: {
    'Content-Type': 'application/ld+json',
    Authorization: `Bearer ${configuration.token}`,
  },
  protocol: 'https:',
  hostname: 'my-api.com',
  port: 443,
  path: `/api${configuration.remoteFile}`,
};

ipcMain.on('request-mainprocess-action', (event, arg) => {
  const req = net.request(arg);
});

I run my request in main.js file (main process).
Anyone have already use net module in Electron app ?
Thank you !

A:

It doesn't look like you're using it as per the docs:
const {app} = require('electron')
app.on('ready', () => { 
  const {net} = require('electron') 
  const request = net.request('https://github.com')
  request.on('response', (response) => { 
  console.log(`STATUS: ${response.statusCode}`)
  console.log(`HEADERS: ${JSON.stringify(response.headers)}`) 
  response.on('data', (chunk) =>
   { console.log(`BODY: ${chunk}`)
})

