src/request.js
function do_js(url, opts) {
	opts = opts || {};
	if(is.object(opts) && is['function'](opts.body)) {
		opts.body = FUNCTION(opts.body).stringify();
	} else if(is.object(opts) && is.string(opts.body)) {
	} else {
		throw new TypeError('opts.body is not function nor string');
	}
	opts.headers = opts.headers || {};
	if(opts.body) {
		opts.headers['Content-Type'] = 'application/javascript;charset=utf8';
	}

	// Default method should be POST since JavaScript code usually might change something.
	if(!opts.method) {
		opts.method = 'post';
	}

	opts.headers.Accept = 'application/json';
	return do_plain(url, opts).then(function(buffer) {
		return JSON.parse(buffer);
	});
}
function do_js(url, opts) {
	opts = opts || {};
	if(is.object(opts) && is['function'](opts.body)) {
		opts.body = FUNCTION(opts.body).stringify();
	} else if(is.object(opts) && is.string(opts.body)) {
	} else {
		throw new TypeError('opts.body is not function nor string');
	}
	opts.headers = opts.headers || {};
	if(opts.body) {
		opts.headers['Content-Type'] = 'application/javascript;charset=utf8';
	}

	// Default method should be POST since JavaScript code usually might change something.
	if(!opts.method) {
		opts.method = 'post';
	}

	opts.headers.Accept = 'application/json';
	return do_plain(url, opts).then(function(buffer) {
		return JSON.parse(buffer);
	});
}
function do_js ( url , opts ) { opts = opts || { } ; if ( is . object ( opts ) && is [ 'function' ] ( opts . body ) ) { opts . body = FUNCTION ( opts . body ) . stringify ( ) ; } else if ( is . object ( opts ) && is . string ( opts . body ) ) { } else { throw new TypeError ( 'opts.body is not function nor string' ) ; } opts . headers = opts . headers || { } ; if ( opts . body ) { opts . headers [ 'Content-Type' ] = 'application/javascript;charset=utf8' ; } // Default method should be POST since JavaScript code usually might change something. if ( ! opts . method ) { opts . method = 'post' ; } opts . headers . Accept = 'application/json' ; return do_plain ( url , opts ) . then ( function ( buffer ) { return JSON . parse ( buffer ) ; } ) ; }
JavaScript function request
JavaScript function request