Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are these console.log statements not working? Electron

I am trying to test something here.

I am using electron and javascript. I am trying to load a profile into the page when a user selects it. None of my console log statements are showing in the console, however when the user makes the "profileSelect" change event, the values are loaded correctly. The reason I am testing this is because I am trying to add an addition to this file, checking a checkbox (it's not working either).

profileSelect.change(function(event) {
    //If the value isn't null
    console.log('yo')
    if (profileSelect.val() == '') {
        clearBilling();
    } else {
        ipcRenderer.once(profileSelect.val() + 'profileData', function(event, data) {
            //Return card to style it was first added like
            console.log('sshi')
            //This allows us to parse the data on profile save
            const cardParse = String(data.card.number).match(/.{3,4}/g).join(' ')
            const dateParse = String(data.card.month) + ' / ' + String(data.card.year);
            profileName.val(profileSelect.val());
            billingFirstName.val(data.billing.firstName);
            billingLastName.val(data.billing.lastName);
            billingAddress1.val(data.billing.address1);
            billingAddress2.val(data.billing.address2);
            billingCity.val(data.billing.city);
            billingState.val(data.billing.state);
            billingZipcode.val(data.billing.zipcode);
            billingCountry.val(data.billing.country);
            billingPhone.val(data.billing.phone);
            billingEmail.val(data.email);
            shippingFirstName.val(data.shipping.firstName);
            shippingLastName.val(data.shipping.lastName);
            shippingAddress1.val(data.shipping.address1);
            shippingAddress2.val(data.shipping.address2);
            shippingCity.val(data.shipping.city);
            shippingState.val(data.shipping.state);
            shippingZipcode.val(data.shipping.zipcode);
            shippingCountry.val(data.shipping.country);
            shippingPhone.val(data.shipping.phone);
            cardName.val(data.card.name);
            cardNumber.val(cardParse);
            cardCVV.val(data.card.code);
            cardExpire.val(dateParse);
        })
        //Send the selected profile
        ipcRenderer.send('requestProfile', profileSelect.val())
    }
})

Why aren't the console log statements logging? Thanks for any input :)

like image 308
lylecarlson Avatar asked Oct 20 '25 21:10

lylecarlson


1 Answers

Electron has 2 processes, and hence 2 consoles. The 2 processes are main and renderer, main being a node.js process, renderer being a browser process.

Main process console.log would be shown in the terminal (if running in dev) or in the browser console window if in the renderer process.

You seem to be logging from the renderer process as per the ipcRenderer statements.

The renderer console can be shown via the standard chrome devtools shortcut (as its running a chrome instance) (usually F12)

You won't be able to see any console statements from renderer in main, or main in renderer.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!