Answer the question
In order to leave comments, you need to log in
How to change new Promise to util.promisify?
How can this function be rewritten to util.promisify?
Location.getLocationByUrlSlugWithPromise = function(urlSlug) {
return new Promise((resolve, reject) => {
Location.getLocationByUrlSlug(urlSlug, (error, location) => {
if (error) {
return reject(error);
}
if (location) {
return resolve(location);
}
return relose(null);
});
})
}
Answer the question
In order to leave comments, you need to log in
Something like this:
Location.getLocationByUrlSlugWithPromise = util.promisify(Location.getLocationByUrlSlug.bind(Location));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question