{"id":27884,"library":"jsonpipe","title":"jsonpipe","description":"jsonpipe is a lightweight, standalone AJAX client for consuming chunked (Transfer-Encoding: chunked) JSON responses in the browser. Version 2.2.0 (latest) ships TypeScript types. It exposes a single `flow` function with an API similar to jQuery.ajax, but tailored for streaming JSON delimited by double newlines (`\\n\\n`). No dependencies, supports IE8+, and allows per-chunk callbacks. Differentiators: minimal footprint, automatic delimiter-based JSON parsing, and configurable delimiter.","status":"active","version":"2.2.0","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/eBay/jsonpipe","tags":["javascript","typescript"],"install":[{"cmd":"npm install jsonpipe","lang":"bash","label":"npm"},{"cmd":"yarn add jsonpipe","lang":"bash","label":"yarn"},{"cmd":"pnpm add jsonpipe","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM and TypeScript: named import. The default export is the flow function itself, but named import is correct for TS. No default export exists.","wrong":"const jsonpipe = require('jsonpipe');\njsonpipe.flow(...);","symbol":"flow","correct":"import { flow } from 'jsonpipe';"},{"note":"If using ESM without named imports, default import works. But TypeScript types recommend named import.","wrong":"const jsonpipe = require('jsonpipe').default;","symbol":"jsonpipe (default)","correct":"import jsonpipe from 'jsonpipe';"},{"note":"CommonJS require returns a function (the flow function) directly. Destructuring will fail.","wrong":"const { flow } = require('jsonpipe');","symbol":"jsonpipe (CommonJS)","correct":"const jsonpipe = require('jsonpipe');"}],"quickstart":{"code":"import { flow } from 'jsonpipe';\n\n// Sample endpoint that returns chunked JSON separated by \\n\\n\nflow('https://api.example.com/stream', {\n  success: (data) => {\n    console.log('Received chunk:', data);\n  },\n  error: (msg) => {\n    console.error('Error:', msg);\n  },\n  complete: (statusText) => {\n    console.log('Request completed with status:', statusText);\n  },\n  timeout: 5000,\n  method: 'GET'\n});","lang":"typescript","description":"Initializes a streaming GET request that logs each JSON chunk as it arrives, along with error and completion handlers."},"warnings":[{"fix":"Set `delimiter` in the options object to the correct separator string.","message":"jsonpipe expects JSON objects separated by double newline (`\\n\\n`) by default. If the server uses a different delimiter, you must set the `delimiter` option.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set `disableContentType: true` when sending non-string data.","message":"The `data` option sends a request body. If `data` is not a string (e.g., FormData, File, Blob), you must set `disableContentType: true` to avoid overwriting the Content-Type header.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use in browser context only. For Node.js streaming, consider alternatives like `fetch` with ReadableStream.","message":"jsonpipe only works in browser environments (IE8+). It relies on XMLHttpRequest and is not compatible with Node.js or server-side rendering.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Access individual header values via `headers['Content-Type']` or similar.","message":"The `onHeaders` callback receives arguments (statusText, headers) but `headers` is an object, not a string. Some users expect a string header.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"Use `const jsonpipe = require('jsonpipe'); jsonpipe.flow(...);` instead of `const { flow } = require('jsonpipe');`","cause":"Using CommonJS destructuring on the require result, which is a function, not an object.","error":"TypeError: Cannot read property 'flow' of undefined"},{"fix":"Ensure server sends valid JSON objects separated by `\\n\\n` and set the correct `delimiter` option if different.","cause":"Server returns HTML or invalid JSON; or delimiter not set correctly causing malformed chunks.","error":"Uncaught SyntaxError: Unexpected token < in JSON at position 0"},{"fix":"Check server CORS headers and ensure `withCredentials` is used only if the server allows credentials.","cause":"The request was aborted or a network issue occurred; or `withCredentials` not supported in some CORS configurations.","error":"NetworkError: Failed to execute 'send' on 'XMLHttpRequest'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}