Works once...then not again? And jumps me to other parts of my code? #107
-
New to javascript and psyched to use this! However, I'm running into two problems I'd love some advice on:
I'm sure I'm missing something obvious in how this works, and I'm still getting comfortable with promises/async/await, but I can't for the life of me figure out why this doesn't work. Thanks! More details I can use exiftool to pull the information for a.mov file using either your first example's format...
...or your second's...
However, I can't get it to work when I move it over to my code, neither using the first method...
...nor the second...
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
If nothing is being output to console, I suspect the main loop is not awaiting your promise chain, so node thinks it can ignore it and exit. Both of the following examples work as expected on Node 16.13.1: A more readable async/await style: const exiftool = require("exiftool-vendored").exiftool;
async function run() {
const tags = await exiftool.read("../../examples/tiny.jpg");
console.log(tags);
await exiftool.end();
console.log("finished.")
}
void run(); And promise .then chains: const exiftool = require("exiftool-vendored").exiftool;
void exiftool
.read("../../examples/tiny.jpg")
.then(console.log)
.then(() => exiftool.end())
.then(() => console.log("finished!")); There are tons of promise tutorials online, BTW. Please check at least a couple of them out. |
Beta Was this translation helpful? Give feedback.
If nothing is being output to console, I suspect the main loop is not awaiting your promise chain, so node thinks it can ignore it and exit.
Both of the following examples work as expected on Node 16.13.1:
A more readable async/await style:
And promise .then chains:
Th…