# dasu

> Consistent xhr API for both client and server (http.request)

Latest version **0.4.3** (published 2021-12-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install dasu
pnpm add dasu
yarn add dasu
bun add dasu
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.3 |
| Published | 2021-12-30 |
| First published | 2016-06-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | talmobi |
| Maintainers | talmobi |

## Links

- npm: https://www.npmjs.com/package/dasu
- Repository: https://github.com/talmobi/dasu
- Homepage: https://github.com/talmobi/dasu#readme
- Issues: https://github.com/talmobi/dasu/issues
- npm.io page: https://npm.io/package/dasu

## Recent versions

- 0.4.3 (latest) — 2021-12-30
- 0.4.2 — 2021-04-01
- 0.4.1 — 2020-07-06
- 0.4.0 — 2020-05-06
- 0.3.0 — 2020-01-21
- 0.2.3 — 2020-01-19
- 0.2.2 — 2020-01-13
- 0.2.1 — 2019-12-30
- 0.2.0 — 2019-09-29
- 0.1.0 — 2018-12-10
- 0.0.23 — 2018-03-01
- 0.0.22 — 2017-11-24
- 0.0.21 — 2017-10-12
- 0.0.20 — 2017-10-12
- 0.0.19 — 2017-01-24
- … 17 more at https://npm.io/package/dasu/versions

## README

[![npm](https://img.shields.io/npm/v/dasu.svg?maxAge=3600)](https://www.npmjs.com/package/dasu)
[![npm](https://img.shields.io/npm/dm/dasu.svg?maxAge=3600)](https://www.npmjs.com/package/dasu)
[![npm](https://img.shields.io/npm/l/dasu.svg?maxAge=3600)](https://www.npmjs.com/package/dasu)
![macos](https://github.com/talmobi/dasu/workflows/macos/badge.svg)
![windows](https://github.com/talmobi/dasu/workflows/windows/badge.svg)
![ubuntu](https://github.com/talmobi/dasu/workflows/ubuntu/badge.svg)

# 出す　ー　dasu
## The same xhr API for both client and server

Simple to use:
```javascript
var dasu = require('dasu')
var req = dasu.req

// same params as Node's require('http').request
var params = {
  method: 'GET',
  protocol: 'http',
  hostname: 'uinames.com',
  port: 80,
  path: '/api/',
}

req(params, function (err, res, data) {
  console.log(res.statusCode)
  console.log(res.headers)
  var json = JSON.parse(data)
  console.log(json)
  // eg: {"name":"Milica","surname":"Maslo","gender":"female","region":"Slovakia"}
})


// turn auto-follow redirects off
dasu.follow = false

// force mode 'node', 'browser', 'auto'
// (useful with Electron etc)
dasu.mode = 'auto' // uses window.XMLHttpRequest if available
```

## Test in browser
https://runkit.com/talmobi/runkit-npm-dasu

## About
Using XMLHttpRequest or Node's http libraries under the hood, **dasu** aims to streamline your basic xhr for both contexts. It provides the familiar structure to Node's http library (http://devdocs.io/node/http#http_http_request_options_callback)


## Why
Test your client side request/fetch/xhr logic on the server side with the same api you're using on the client.

## Alternatives
https://github.com/visionmedia/superagent


## Install
from npm
```
npm install --save dasu
```

from source
```
git clone https://github.com/talmobi/dasu
cd dasu
npm install
```


## Test
```
git clone https://github.com/talmobi/dasu
cd dasu
npm install
npm test
```

---
_Source: https://npm.io/package/dasu · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
