Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dialog.showOpenDialog doesn't return an array of string but a promise. #6

Open
ghost opened this issue Jul 1, 2020 · 1 comment
Open

Comments

@ghost
Copy link

ghost commented Jul 1, 2020

Listing 4.2 doesn't work since dialog.showOpenDialog doesn't return an array of string but a promise according to the doc.
Hence the listing 4.2 need to be modify in order to take it into account.

const getFileFromUser = () => {
  const files = dialog.showOpenDialog({
    properties: ["openFile"],
  });
  files
    .then((value) => {
      if (value.canceled == true) return;
      console.log(value.filePaths);
    })
    .catch((err) => console.log(err));
};
@robertpatrick
Copy link

Change showOpenDialog to showOpenDialogSync. There are a number of places where the code doesn't work in current versions of Electron.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant