Closed prezzemolo closed 7 years ago
import * as client from "cheerio-httpcli";
/**
@returns {Promise} object extends CheerioStatic */ const wrapper = async (url: string): Promise => { const result = await client.fetch(url); const type: string = result.response.headers['content-type'];
/ rejects / if (result.error !== undefined && result.error !== null) throw "happend-error"; if (! /text\/html/.test(type)) throw "not-html";
/ resolve result / return result.$; };
wrapper('https://github.com/prezzemolo').then(result => { console.dir(result); });
/**
@returns {Promise} object extends CheerioStatic
*/
const wrapper = async (url: string): Promise => {
const result = await client.fetch(url);
const type: string = result.response.headers['content-type'];
/ rejects / if (result.error !== undefined && result.error !== null) throw "happend-error"; if (! /text\/html/.test(type)) throw "not-html";
/ resolve result / return result.$; };
wrapper('https://github.com/prezzemolo').then(result => { console.dir(result); });