[{"data":1,"prerenderedAt":87},["Reactive",2],{"/samples/node/superagent":3,"related:QEHXQdkiH7":61},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"language":10,"library":11,"link":12,"body":13,"_type":56,"_id":57,"_source":58,"_file":59,"_extension":60},"/samples/node/superagent","node",false,"","Superagent","SuperAgent is a feature-rich HTTP client for Node.js and the browser. It provides an intuitive API for making HTTP requests and handling responses. Superagent supports features like request chaining, form data encoding, and streaming responses.","Node","SuperAgent","https://www.npmjs.com/package/superagent",{"type":14,"children":15,"toc":53},"root",[16,31,44],{"type":17,"tag":18,"props":19,"children":20},"element","p",{},[21,29],{"type":17,"tag":22,"props":23,"children":26},"a",{"href":12,"rel":24},[25],"nofollow",[27],{"type":28,"value":11},"text",{"type":28,"value":30}," is a feature-rich HTTP client for Node.js and the browser. It provides an intuitive API for making HTTP requests and handling responses. Superagent supports features like request chaining, form data encoding, and streaming responses.",{"type":17,"tag":32,"props":33,"children":38},"pre",{"className":34,"code":36,"language":37,"meta":7},[35],"language-javascript","const superagent = require('superagent');\n\nasync function convert(api_key, params, endpoint='pdf') {\n    if (!['pdf', 'png', 'jpg', 'webp'].includes(endpoint)) {\n        throw new Error('Invalid endpoint');\n    }\n\n    let response = await superagent\n        .post(`https://api.pdfshift.io/v3/convert/${endpoint}`)\n        .set('X-API-Key', api_key)\n        .send(params);\n        \n    if ('filename' in params || 'webhook' in params) {\n        // Return in JSON in that case\n        return response.body;\n    }\n\n    // Returns the binary content\n    return response.body;\n}\n","javascript",[39],{"type":17,"tag":40,"props":41,"children":42},"code",{"__ignoreMap":7},[43],{"type":28,"value":36},{"type":17,"tag":32,"props":45,"children":48},{"className":46,"code":47,"language":37,"meta":7},[35],"const binary = await convert('sk_XXXXXXXXXXXXXX', {source: 'https://en.wikipedia.org/wiki/REST'})\nrequire('fs').writeFileSync('result.pdf', binary);\n",[49],{"type":17,"tag":40,"props":50,"children":51},{"__ignoreMap":7},[52],{"type":28,"value":47},{"title":7,"searchDepth":54,"depth":54,"links":55},2,[],"markdown","content:samples:node:superagent.md","content","samples/node/superagent.md","md",[62,66,70,74,78,82,83],{"_path":63,"language":10,"library":64,"_id":65},"/samples/node/axios","Axios","content:samples:node:axios.md",{"_path":67,"language":10,"library":68,"_id":69},"/samples/node/bent","Bent","content:samples:node:bent.md",{"_path":71,"language":10,"library":72,"_id":73},"/samples/node/got","Got","content:samples:node:got.md",{"_path":75,"language":10,"library":76,"_id":77},"/samples/node/needle","Needle","content:samples:node:needle.md",{"_path":79,"language":10,"library":80,"_id":81},"/samples/node/node-fetch","Node Fetch","content:samples:node:node-fetch.md",{"_path":4,"language":10,"library":11,"_id":57},{"_path":84,"language":10,"library":85,"_id":86},"/samples/node/unfetch","Unfetch","content:samples:node:unfetch.md",1785426823261]