{"id":10715,"library":"dasu","title":"dasu: Consistent XHR API for Client and Server","description":"dasu is a JavaScript library that aimed to provide a consistent XMLHttpRequest (XHR) API for both client-side (browser) and server-side (Node.js) environments. It abstracts away the underlying differences between `window.XMLHttpRequest` and Node's `http.request`, presenting a unified interface. The library, currently at version 0.4.3, was last published in June 2014. Its primary differentiator was simplifying basic HTTP requests with a single API across environments, which was particularly useful before the widespread adoption of Fetch API or more mature cross-platform libraries. Due to its age and lack of updates, it does not support modern JavaScript features like Promises or `async/await` and relies exclusively on CommonJS modules.","status":"abandoned","version":"0.4.3","language":"javascript","source_language":"en","source_url":"https://github.com/talmobi/dasu","tags":["javascript"],"install":[{"cmd":"npm install dasu","lang":"bash","label":"npm"},{"cmd":"yarn add dasu","lang":"bash","label":"yarn"},{"cmd":"pnpm add dasu","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"dasu is a CommonJS module, published in 2014. It does not provide ESM exports.","wrong":"import { req } from 'dasu';","symbol":"req","correct":"const dasu = require('dasu');\nconst req = dasu.req;"},{"note":"The entire library is exposed as a single CommonJS module export. Destructuring imports will not work as expected for non-exported properties.","wrong":"import dasu from 'dasu';","symbol":"dasu","correct":"const dasu = require('dasu');"}],"quickstart":{"code":"const dasu = require('dasu');\nconst req = dasu.req;\n\n// Same parameters as Node's require('http').request\nconst params = {\n  method: 'GET',\n  protocol: 'http',\n  hostname: 'uinames.com',\n  port: 80,\n  path: '/api/',\n};\n\nreq(params, function (err, res, data) {\n  if (err) {\n    console.error('Request failed:', err.message);\n    return;\n  }\n  console.log('Status Code:', res.statusCode);\n  console.log('Headers:', res.headers);\n  try {\n    const json = JSON.parse(data);\n    console.log('Response Data:', json);\n  } catch (parseError) {\n    console.error('Failed to parse JSON:', parseError.message);\n    console.log('Raw Data:', data.toString());\n  }\n});\n\n// Optionally, disable auto-follow redirects\ndasu.follow = false;\n\n// Optionally, force mode 'node', 'browser', 'auto'\ndasu.mode = 'auto'; // Uses window.XMLHttpRequest if available","lang":"javascript","description":"This quickstart demonstrates how to make a GET request using dasu's `req` function with Node.js-style options and a callback."},"warnings":[{"fix":"Migrate to a modern HTTP client library such as `axios`, `node-fetch`, or the built-in `fetch` API for browsers/Node.js.","message":"The `dasu` package is severely outdated, with its last release (0.4.3) dating back to June 2014. It has not received updates for over a decade and is considered abandoned. It lacks modern JavaScript features, security patches, and bug fixes.","severity":"breaking","affected_versions":"<=0.4.3"},{"fix":"Wrap dasu calls in Promises if necessary (e.g., using `util.promisify` in Node.js) or, preferably, switch to a modern library that natively supports Promises.","message":"dasu relies on a traditional Node.js callback pattern for asynchronous operations (`(err, res, data) => {}`). It does not support Promises, async/await syntax, or other modern async control flow mechanisms, making integration with contemporary JavaScript codebases challenging.","severity":"gotcha","affected_versions":"<=0.4.3"},{"fix":"Use `const dasu = require('dasu');` in Node.js environments. For browser environments, use script tags or a CJS-compatible bundler if absolutely necessary.","message":"The library primarily supports CommonJS module syntax (`require`). There are no official ES module (ESM) exports, meaning direct `import` statements will fail without a CommonJS-to-ESM transpilation step, which is generally not recommended for abandoned libraries.","severity":"gotcha","affected_versions":"<=0.4.3"},{"fix":"Explicitly set `dasu.mode = 'node'` or `dasu.mode = 'browser'` if you are in a hybrid environment like Electron to ensure the correct underlying HTTP implementation is used.","message":"The `dasu.mode` property allows forcing 'node', 'browser', or 'auto'. In environments like Electron or certain testing setups, `dasu.mode = 'auto'` might incorrectly detect the environment, leading to unexpected behavior or API mismatches.","severity":"gotcha","affected_versions":"<=0.4.3"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Use CommonJS `require` syntax: `const dasu = require('dasu'); const req = dasu.req;`","cause":"Attempting to use `import dasu from 'dasu'` or `import { req } from 'dasu'` with a CommonJS-only library.","error":"TypeError: dasu is not a function or dasu.req is undefined"},{"fix":"Ensure `params.protocol` is correctly specified as `'http:'` or `'https:'` (including the colon) and matches the target server's protocol.","cause":"Incorrect or missing `protocol` in the request `params` object, especially when making requests to non-standard ports or local services.","error":"Error: Protocol 'http:' not supported. Expected 'http:' or 'https:'"},{"fix":"Ensure the second argument passed to `dasu.req` is a standard Node.js-style callback function with `(err, res, data)` arguments.","cause":"The second argument to `dasu.req` is not a function, or a Promise/async/await syntax was mistakenly used.","error":"Callback must be a function."}],"ecosystem":"npm"}