I have just finished writing this code snippet:
function getScreenshotObj (pathToFirstFile) {
return new Promise ((resolve,reject) =>{
console.log("The path to the temporary directory is: " + pathToFirstFile)
fs.readFile(pathToFirstFile,function(err,fileContents){
if (err) {
return reject(err)
}
else{
screenshotObject = JSON.parse(fileContents)
obj = {pathToFirstFile : pathToFirstFile , screenshotObject:screenshotObject ,accesstoken : accesstoken}
return resolve(obj)
}
})
})
}
I am encountering an error at JSON.parse(). Specifically, it is giving me an 'Uncaught syntax error: Unexpected end of input' at that line. I have verified the syntax using online JS validators, and they indicate that the code is syntactically correct. Could someone please review my code and point out any mistakes I may have made?