Electron Return Value to Renderer form Main


I have the below code that does a database query, it returns the rows and I see the rows in console.log. However, in the renderer process I do not get the returned rows, console.log shows ‘undefined’. Am I missing something?


exports.accounts = function() {

    db.serialize(function() {
        db.all("select * from accounts", function(err, rows) {
            if (err) {
            } else {
                return rows;

app.js (renderer)

const remote = require('electron').remote;
const main = remote.require('./main.js');
$scope.accounts = main.accounts();


See this previous topic for why you should probably be accessing the database from the renderer side.