New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dasu

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dasu

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

  • 0.4.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

npm npm npm macos windows ubuntu

出す ー dasu

The same xhr API for both client and server

Simple to use:

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

FAQs

Package last updated on 30 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc