Opening files in the book file

I’m trying to open the individual files from an indb file. I’m able to open that book file, and then I’m not able to resolve the files to open them.

// Iterate over each document in the book
    for (let i = 0; i < bookContents.length; i++) {
      const bookContent = bookContents.item(i);
      console.log(`Processing document: ${bookContent.name}`);

      // Open the .indd file
      // verify the bookContent.filePath Promise is valid, and log if it is not.
      bookContent.filePath
        .then((doc) => console.log(`Document: ${doc.name}`))
        .catch((err) => console.error(`Promise Error: ${err}`));

      
      const filePath = bookContent.filePath;

But the promise is never resolved, and I can’t get it to do so, if I add an awaite, like

const filePath = await bookContent.filePath;

it just throws an error immediately.

Should this work? Has anyone done this before? If I double inDesign can open the files fine. So It’s something with permissions or my script.

Thanks for any help.

Note the then/catch is just me trying to figure out why it’s not working.