[{"data":1,"prerenderedAt":86},["Reactive",2],{"/samples/node/bent":3,"related:dIiqDEaAls":60},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"language":10,"library":8,"link":11,"body":12,"_type":55,"_id":56,"_source":57,"_file":58,"_extension":59},"/samples/node/bent","node",false,"","Bent","Bent is a functional programming-style HTTP client for Node.js with support for async/await syntax. It offers a simple and expressive API for making HTTP requests and handling responses using functional programming concepts.","Node","https://github.com/mikeal/bent",{"type":13,"children":14,"toc":52},"root",[15,30,43],{"type":16,"tag":17,"props":18,"children":19},"element","p",{},[20,28],{"type":16,"tag":21,"props":22,"children":25},"a",{"href":11,"rel":23},[24],"nofollow",[26],{"type":27,"value":8},"text",{"type":27,"value":29}," is a functional programming-style HTTP client for Node.js with support for async/await syntax. It offers a simple and expressive API for making HTTP requests and handling responses using functional programming concepts.",{"type":16,"tag":31,"props":32,"children":37},"pre",{"className":33,"code":35,"language":36,"meta":7},[34],"language-javascript","const bent = require('bent')\n\nconst convert = async (apiKey, params, endpoint='pdf') => {\n    if (!['pdf', 'png', 'jpg', 'webp'].includes(endpoint)) {\n        throw new Error('Invalid endpoint')\n    }\n\n    const post = bent(`https://api.pdfshift.io/v3/convert/${endpoint}`, 'POST', 'json', 200)\n\n    const response = await post('', params, {'X-API-Key': apiKey});\n    \n    if ('filename' in params || 'webhook' in params) {\n        return response;\n    }\n    \n    const getBuffer = bent('buffer');\n    const responseBuffer = await getBuffer(response.pdf.url);\n    return responseBuffer;\n}\n","javascript",[38],{"type":16,"tag":39,"props":40,"children":41},"code",{"__ignoreMap":7},[42],{"type":27,"value":35},{"type":16,"tag":31,"props":44,"children":47},{"className":45,"code":46,"language":36,"meta":7},[34],"const fs = require('fs');\nconvert('sk_XXXXXXXXXXXXXX', {'source': 'https://en.wikipedia.org/wiki/REST'})\n    .then((binary) => {\n        fs.writeFile('result.pdf', binary, 'binary', (err) => {\n            if (err) throw err;\n        })\n    });\n",[48],{"type":16,"tag":39,"props":49,"children":50},{"__ignoreMap":7},[51],{"type":27,"value":46},{"title":7,"searchDepth":53,"depth":53,"links":54},2,[],"markdown","content:samples:node:bent.md","content","samples/node/bent.md","md",[61,65,66,70,74,78,82],{"_path":62,"language":10,"library":63,"_id":64},"/samples/node/axios","Axios","content:samples:node:axios.md",{"_path":4,"language":10,"library":8,"_id":56},{"_path":67,"language":10,"library":68,"_id":69},"/samples/node/got","Got","content:samples:node:got.md",{"_path":71,"language":10,"library":72,"_id":73},"/samples/node/needle","Needle","content:samples:node:needle.md",{"_path":75,"language":10,"library":76,"_id":77},"/samples/node/node-fetch","Node Fetch","content:samples:node:node-fetch.md",{"_path":79,"language":10,"library":80,"_id":81},"/samples/node/superagent","SuperAgent","content:samples:node:superagent.md",{"_path":83,"language":10,"library":84,"_id":85},"/samples/node/unfetch","Unfetch","content:samples:node:unfetch.md",1785426823228]