spee.ch/server/lbrynet/utils/handleLbrynetResponse.js
2018-04-26 23:42:22 -07:00

19 lines
499 B
JavaScript

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;