sindresorhus / electron-dl

Simplified file downloads for your Electron app
MIT License
1.15k stars 138 forks source link

TypeError upon evaluation of download() arguments #135

Open Dcai169 opened 3 years ago

Dcai169 commented 3 years ago

I'm trying to use this module to download a file with the following code:

// Main process

ipcMain.on('downloadFile', (event, args) => {
    download(BrowserWindow.fromId(event.frameId), args.url, { directory: args.path }).then((dl) => {
        console.log(dl.getSavePath())
        event.reply('downloadFile-reply', dl.getSavePath());
    });
});

Every time the render process fires the downloadFile event however, I get the following error:

(node:12263) UnhandledPromiseRejectionWarning: TypeError: Error processing argument at index 0, conversion failure from 
    at /Users/daniel_cai/Documents/GitHub/Destiny-API-Ripper-Extension/node_modules/electron-dl/index.js:204:22
    at new Promise (<anonymous>)
    at module.exports.download (/Users/daniel_cai/Documents/GitHub/Destiny-API-Ripper-Extension/node_modules/electron-dl/index.js:190:54)
    at IpcMainImpl.<anonymous> (/Users/daniel_cai/Documents/GitHub/Destiny-API-Ripper-Extension/src/index.js:170:5)
    at IpcMainImpl.emit (events.js:315:20)
    at Object.<anonymous> (electron/js2c/browser_init.js:157:9051)
    at Object.emit (events.js:315:20)

Google search queries did not yield any results. The full source can be found at https://github.com/Dcai169/Destiny-API-Ripper-Extension/commit/136c9b42330bf683ce18550b549949133fc8f8db.

dr34m-cn commented 2 years ago

I have the same problem as you, I wrote the download link wrong