Closed sicter closed 7 years ago
In your code, you need to define status as a callback function. TRY THIS. const converter = require('webp-converter'); const save_webp = (imagePath, cacheTime) => { return new Promise((resolve, reject) => { converter.cwebp(imagePath, imgDestination, "80", function(status) => { //if conversion successfull status will be 'converted successfully' if (status == 'converted successfully') { database.store(imgDestination, cacheTime); resolve(imgDestination); } else { reject(imageConvertError); } }); }); }
(status) => {...} is correct syntax in es6 for a function where status is the parameter, which nodejs supports, and it definitely works with v2.0.1.
function(status) => {...} is invalid js syntax However I did try:
function(status) {...}
which also failed on v2.1.1 but works on v2.0.1. I did not test any versions in between and I am fine with sticking to 2.0.x since I don't need gif conversion. Just wanted to bring up something I saw. Thanks for the quick response
My code is the following:
This code is never able to complete as the app crashes with the error above before the status check. I have since reverted to v2.0.1, which I originally used and it now works, but I do not know specifically what would have caused the error