Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best Javascript framework for RESTful HTTP networking

I am more of a backend guy, but frontend development really intrigues me as I make my first steps in seeing the browser as the environment for rich and awesome applications.

What is the most suitable Javascript framework for working with a RESTful HTTP API, in other words, for retrieving (HTTP GET) and submitting (HTTP POST/PUT/DELETE) JSON representations of resources?

I am looking for a framework (if it exists!) that provides good abstraction and encapsulation of HTTP request/response, handles cross-domain and cross-browser issues.

like image 666
Claudio Donzelli Avatar asked Feb 12 '12 17:02

Claudio Donzelli


People also ask

Which node JS framework is better for building a RESTful API?

LoopBack. js. LoopBack is a highly-extensible, open-source Node. js framework that enables developers to create dynamic end-to-end REST APIs with little or no coding.

Is node JS GOOD FOR REST API?

Node. js has large and active community that contribute many useful and mature modules which can be easily included and used. For example, to construct REST API such known modules as express, restify and hapi fit perfectly.

Can we create REST API using JavaScript?

RESTful APIs can also be designed using programming languages like JavaScript or Python. While REST can be used over nearly any protocol, it is most commonly used for Web APIs over HTTP protocol.


2 Answers

Take a look at Backbone.js http://documentcloud.github.com/backbone/

Its lightweight, does not have many dependencies (only Underscore.js) and its real easy to use, yet pretty flexible and powerful.

From the site;

Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.

like image 106
Marco Avatar answered Sep 24 '22 13:09

Marco


You can use jQuery with its .ajax() function. Example:

$.ajax({
    url: '/users',
    type: 'PUT',
    data: { name: 'John Doe', age: 30 },
    success: function ( data ) {
        alert('John Doe inserted!');
    }
});
like image 24
Eliseu Monar dos Santos Avatar answered Sep 23 '22 13:09

Eliseu Monar dos Santos