dennnisk/ocr-space-api

ERROR: ReferenceError: deferred is not defined

OscarVargasG opened this issue · 3 comments

Node: v9.4.0

const ocrSpaceApi = require("ocr-space-api");

// Image file to upload
const imageFilePath = "../uploads/invoices/myimage.png";

function test(req, res) {
// Run and wait the result

var options = {
apikey: "my apikey",
language: "por", // Português
imageFormat: "image/png"
isOverlayRequired: true
};

// Run and wait the result
ocrSpaceApi
.parseImageFromLocalFile(imageFilePath, options)
.then(function(parsedResult) {
console.log("parsedText: \n", parsedResult.parsedText);
console.log("ocrParsedResult: \n", parsedResult.ocrParsedResult);
res.status(200).send({ parsedResult });
})
.catch(function(err) {
console.log("ERROR:", err);
res.status(200).send({ message: err });
});
}

ERROR:

ERROR: ReferenceError: deferred is not defined
at C:\Development\wamp64\www\node_projects\ocr_project\node_modules\ocr-space-api\lib\ocrSpaceApi.js:59:21
at new Promise ()
at _sendRequestToOcrSpace (C:\Development\wamp64\www\node_projects\ocr_project\node_modules\ocr-space-api\lib\ocrSpaceApi.js:37:12)
at Object.exports.parseImageFromLocalFile (C:\Development\wamp64\www\node_projects\ocr_project

same problem here

Replace deferred.reject() with reject().

Can confirm this works!

However I do get an error message about a file not being found... Probably unrelated.