const logger = require('winston'); const handleLbrynetResponse = ({ data }, resolve, reject) => { logger.debug('lbry api data:', data); if (data.result) { // check for an error if (data.result.error) { logger.debug('Lbrynet api error:', data.result.error); reject(new Error(data.result.error)); return; }; resolve(data.result); return; } // fallback in case it just timed out reject(JSON.stringify(data)); }; module.exports = handleLbrynetResponse;