{"id":27394,"library":"shred","title":"shred","description":"Shred is a resource-oriented HTTP client for JavaScript/Node.js that allows declarative definition of API wrappers with support for URL templates, response compression, authorization, and streaming. The current version is 1.1.0-alpha-10 (alpha quality). It is a complete reboot from 1.0.x, not backwards compatible. Key differentiator: declarative resource definition using CoffeeScript/JavaScript objects, focusing on HTTP resource abstraction rather than low-level requests.","status":"active","version":"1.1.0-alpha-10","language":"javascript","source_language":"en","source_url":"git://github.com/pandastrike/shred","tags":["javascript","http","client"],"install":[{"cmd":"npm install shred","lang":"bash","label":"npm"},{"cmd":"yarn add shred","lang":"bash","label":"yarn"},{"cmd":"pnpm add shred","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core library written in CoffeeScript; may require it for development or interpretation","package":"coffee-script","optional":true}],"imports":[{"note":"Default export is not provided; named export 'resource' is the main entry point. ESM only in v1.x.","wrong":"const shred = require('shred');","symbol":"resource","correct":"import { resource } from 'shred'"},{"note":"Used for explicit invocation of request functions.","symbol":"invoke","correct":"import { invoke } from 'shred'"},{"note":"TypeScript users may need to import type for responses.","symbol":"ShredResponse","correct":"import type { ShredResponse } from 'shred'"}],"quickstart":{"code":"const { resource } = require('shred');\nconst github = resource('https://api.github.com/', {\n  repos: (resource) => resource('repos/{owner}/{repo}/', {\n    issues: (resource) => resource('issues', {\n      list: { method: 'get', headers: { accept: 'application/vnd.github.v3.raw+json' }, expect: 200 }\n    })\n  })\n});\nasync function main() {\n  try {\n    const { data } = await github.repos({ owner: 'user', repo: 'repo' }).issues.list();\n    console.log(data);\n  } catch (error) {\n    console.error(error);\n  }\n}\nmain();","lang":"javascript","description":"Defines a GitHub API client using shred's resource-oriented approach and performs a simple issue listing request."},"warnings":[{"fix":"Update code to use new resource-based declarative API; see README for migration guide.","message":"Shred 1.0.x is a complete reboot and not backwards compatible with earlier versions (0.x).","severity":"breaking","affected_versions":">=1.0.0 <2.0.0"},{"fix":"Pin to specific version and test thoroughly when upgrading.","message":"Shred 1.x is alpha quality; API may change before stable release.","severity":"deprecated","affected_versions":">=1.0.0 <2.0.0"},{"fix":"Use await on response.data to get parsed JSON or string body.","message":"Response 'data' is a promise that resolves when streaming finishes; must be awaited.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use library's documented template syntax.","message":"URL templates use colon syntax (e.g., '/:id') not '{id}' pattern in some versions; verify README.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"const { data } = await request();","cause":"Forgetting to await the response object before accessing .data.","error":"TypeError: Cannot read properties of undefined (reading 'data')"},{"fix":"Check server response or set headers appropriately.","cause":"Non-JSON response parsed as JSON because content-type indicated JSON but body is not valid JSON.","error":"Error: Unexpected token o in JSON at position 1"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}