Skip to content
Lightweight library for making CouchDB requests, based on jQuery
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
README.md
index.js
package.json

README.md

couchr-browser

Lightweight request library for CouchDB. Provides a browser-compatible module, with better CouchDB error reporting and a simpler API than making XHR requests directly in the browser or using jQuery.ajax.

This package is designed to be suitable for use with webpack or browserify, and makes use of the events module (for the changes feed). You can pass in any jQuery.ajax compatible API to initialize the module (allowing you to use your favourite library for this). I suggest taking a look at reqwest if you don't need full jQuery.

Comes in around 5.9kb minified (2.2kb gzipped)

Examples

var couchr = require('couchr-browser')(jQuery.ajax);

couchr.get('http://hostname:port/dbname/docid', function (err, doc) {
    ...
});

Methods

var couchr = require('couchr-browser')(jQuery.ajax);
var couchr = require('couchr-browser')(reqwest.compat);

couchr.get (url, /*optional*/params, function (err, res, req) { ... })
couchr.post(url, /*optional*/data,   function (err, res, req) { ... })
couchr.put (url, /*optional*/data,   function (err, res, req) { ... })
couchr.del (url, /*optional*/data,   function (err, res, req) { ... })
couchr.head(url, function (err, res, req) { ... })

couchr.copy(from, to, function (err, res, req) { ... }) 

var feed = couchr.changes(db_url);
feed.on('change', function (change_object) { ...  });
feed.on('error', function (err) { ...  });
feed.pause();
feed.resume();

Installation

npm install couchr-browser

Building stand-alone version

npm run build
You can’t perform that action at this time.