[scraper] handles non json tpb request results

This commit is contained in:
TheBeastLT
2020-04-26 11:40:01 +02:00
parent 0be7dc4638
commit ee24dbebb8

View File

@@ -102,7 +102,12 @@ function browse(config = {}, retries = 2) {
async function _request(endpoint) {
const url = `${baseUrl}/${endpoint}`;
return needle('get', url, { open_timeout: timeout })
.then(response => response.body);
.then(response => {
if (typeof response.body === 'object') {
return response.body;
}
return Promise.reject(`Unexpected response body`);
});
}
function toTorrent(result) {