JavaScript REST client Library [closed]

2019-01-04 15:31发布

Is there a JavaScript library which allow me to perform all the REST operation like (GET, POST, PUT and DELETE over HTTP or HTTPS)?

9条回答
Emotional °昔
2楼-- · 2019-01-04 16:21

You can try restful.js, a framework-agnostic RESTful client, using a syntax similar to the popular Restangular.

查看更多
爷的心禁止访问
3楼-- · 2019-01-04 16:22

You don't really need a specific client, it's fairly simple with most libraries. For example in jQuery you can just call the generic $.ajax function with the type of request you want to make:

$.ajax({
    url: 'http://example.com/',
    type: 'PUT',
    data: 'ID=1&Name=John&Age=10', // or $('#myform').serializeArray()
    success: function() { alert('PUT completed'); }
});

You can replace PUT with GET/POST/DELETE or whatever.

查看更多
Emotional °昔
4楼-- · 2019-01-04 16:22

jQuery has JSON-REST plugin with REST style of URI parameter templates. According to its description example of using is the followin: $.Read("/{b}/{a}", { a:'foo', b:'bar', c:3 }) becomes a GET to "/bar/foo?c=3".

查看更多
登录 后发表回答