src/index.js
/**
 * Simple client-side API for fast RESTful implementation for lavarel 5.4 backend.
 * Call:
 *   - $.rest('<index|create|show|edit|store|update|destroy>, [Object], <URL>)
 *   - $.rest('default', [Object])
 * 
 * @copyright 2017 Ludwig Meysel
 * @license MIT
 */
Simple client-side API for fast RESTful implementation for lavarel 5.4 backend.

@copyright 2017 Ludwig Meysel
@license MIT
Simple client - side API for fast RESTful implementation for lavarel 5 . 4 backend . @copyright 2017 Ludwig Meysel @license MIT
function execRest() {
	var c = arguments[0];
	if (c == 'default') {
		$.extend(defaults, arguments[1]);
		return;
	}
	if (typeof (rest[c]) != 'function')
		throw new Error('Invalid REST command "' + c + '".');
	if (arguments.length > 1 && typeof (arguments[1]) != 'object')
		throw new Error('Invalid argument. Object expected');
	var a = false,
		cb = false;
	for (var i = 1; i < 3; i++)
		if (arguments[i]) {
			if (typeof (arguments[i]) == 'function')
				cb = arguments[i]
			else
				a = p(arguments[i]);
		}
	if (!a) a = defaults;
	if (a.url.lastIndexOf('/') == (a.url.length - 1))
		a.url = a.url.substring(0, a.url.length - 1);
	if (a.csrf_token)
		arguments[1] = $.extend({ '_token': a.csrf_token }, arguments[1])
	rest[c](arguments[1], a, cb);
}
function execRest ( ) { var c = arguments [ 0 ] ; if ( c == 'default' ) { $ . extend ( defaults , arguments [ 1 ] ) ; return ; } if ( typeof ( rest [ c ] ) != 'function' ) throw new Error ( 'Invalid REST command "' + c + '".' ) ; if ( arguments . length > 1 && typeof ( arguments [ 1 ] ) != 'object' ) throw new Error ( 'Invalid argument. Object expected' ) ; var a = false , cb = false ; for ( var i = 1 ; i < 3 ; i ++ ) if ( arguments [ i ] ) { if ( typeof ( arguments [ i ] ) == 'function' ) cb = arguments [ i ] else a = p ( arguments [ i ] ) ; } if ( ! a ) a = defaults ; if ( a . url . lastIndexOf ( '/' ) == ( a . url . length - 1 ) ) a . url = a . url . substring ( 0 , a . url . length - 1 ) ; if ( a . csrf_token ) arguments [ 1 ] = $ . extend ( { '_token' : a . csrf_token } , arguments [ 1 ] ) rest [ c ] ( arguments [ 1 ] , a , cb ) ; }
Simple client-side API for fast RESTful implementation for lavarel 5.4 backend.
Simple client - side API for fast RESTful implementation for lavarel 5 . 4 backend .