How can I use .then() chaining to call a function that is declared in Node.js? The problem is after the call to getFileType() I want to call getExif() but this is throwing a syntax error:
'use strict';
const FileType = require('file-type');
const exif = require('jpeg-exif');
const path = './alcatraz.jpg';
async function getFileType(filePath) {
return await FileType.fromFile(filePath);
}
function getExif(filePath) {
return new Promise((resolve, reject) => {
exif.parse(filePath, (error, result) => {
if(error) {
reject(error);
} else {
resolve(result);
}
});
});
}
getFileType(path).then((result) => {
console.log(result);
})
# ======> problem is here <======
.then(getExif(path) {
console.log(result);
})
.catch((error) => {
console.error(error.message);
process.exit(3);
});
Syntax error is:
SyntaxError: missing ) after argument list