Net.reuest in electron

I have been working on sending http requests to my PHP code. For that purpose I was suggested to use net API. So, I wrote the code using the net API. I am getting an error in my console.

“Uncaught TypeError: Cannot read property ‘request’ of undefined”

My code is as follows:-

const { net } = require(‘electron’);
const request = net.request({
method: ‘POST’,
protocol: ‘http:’,
hostname: ‘localhost’,
path: ‘/verify/verify.php’
request.on(‘response’, (response) => {
console.log(STATUS: ${response.statusCode})
console.log(HEADERS: ${JSON.stringify(response.headers)})
response.on(‘data’, (chunk) => {
console.log(BODY: ${chunk})
response.on(‘end’, () => {
console.log(‘No more data in response.’)

Please help me.Awaiting your response.

Where is this code? The net API is only available in the main process. If you’re trying to use it inside a window, it will not work, and you need to use IPC to communicate across, or have your window use the Node http API (renderer processes have access to Node modules as normal).

I don’t personally know what the difference is. That’s beyond my pay grade.