{"library":"simple-get","title":"simple-get","description":"simple-get is a minimalist HTTP client library for Node.js, providing the simplest way to make HTTP GET requests with essential features like HTTPS support, automatic redirect following, and gzip/deflate decompression. It focuses on being a lightweight wrapper (under 120 lines of code) around Node.js's native `http` and `https` modules, minimizing overhead. The current stable version is 4.0.1. It maintains a stable API, primarily using callback patterns, and is known for its reliability and efficiency in basic request scenarios. Key differentiators include its small footprint and stream-first approach, making it ideal for scenarios where a full-featured HTTP client is overkill, or when composing with other stream-based utilities.","language":"javascript","status":"active","last_verified":"Wed Apr 22","install":{"commands":["npm install simple-get"],"cli":null},"imports":["const get = require('simple-get')","const get = require('simple-get'); get.concat('http://example.com', cb)","const get = require('simple-get'); get.post(opts, cb)"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const get = require('simple-get');\n\nasync function fetchData() {\n  const url = 'https://jsonplaceholder.typicode.com/posts/1';\n  console.log(`Fetching data from: ${url}`);\n\n  return new Promise((resolve, reject) => {\n    get.concat(url, function (err, res, data) {\n      if (err) {\n        console.error('Request failed:', err.message);\n        return reject(err);\n      }\n      if (res.statusCode !== 200) {\n        console.error(`Received status code ${res.statusCode}`);\n        return reject(new Error(`Server responded with status ${res.statusCode}`));\n      }\n      try {\n        const json = JSON.parse(data.toString());\n        console.log('Received data successfully:');\n        console.log(json);\n        resolve(json);\n      } catch (parseErr) {\n        console.error('Failed to parse JSON:', parseErr.message);\n        reject(parseErr);\n      }\n    });\n  });\n}\n\nfetchData().catch(e => console.error('Overall error:', e.message));","lang":"javascript","description":"Demonstrates a basic GET request using `get.concat` to fetch and parse JSON data from a public API, including error handling for network issues and non-200 responses.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}