Problem with format () in an Electron app

Viewed 1679

I'm trying to make an app in Electron js but the url doesn't load. The problem is in the format () function which appears strikethrough. It is apparently deprecated (@deprecated -- since v11.0.0 - User the WHATWG URL API). I need help!

...

app.on('ready', function() {
    mainWindow = new BrowserWindow({});
    
    mainWindow.loadURL(url.format({
        pathname: path.join(__dirname, 'mainWindow.html'),
        protocol: 'file:',
        slashes: true
    }));
});
1 Answers

What worked for me was:

mainWindow.loadURL(path.join(__dirname, 'mainWindow.html'));

What it does is basically return "C:\__dirname\mainWindow.html"

Related