How to use the request function from restler

Find comprehensive JavaScript restler.request code examples handpicked from public code repositorys.

30
31
32
33
34
35
36
37
38
39
  options.headers['Content-Type'] = 'application/json';
}

options.parser = rest.parsers.json;

rest.request(this.url(url), options).addListener('success', function(data) {
  p.emitSuccess(data);
}).addListener('error', function(data) {
  p.emitError(data);
});
fork icon0
star icon11
watch icon3

25
26
27
28
29
30
31
32
33
34
    options.username=username;
    options.password=password;
}
//获取url
var url = $('#inputUrl').val();
rest.request(url,options).on("timeout",function(ms){
    //输出超时信息
    $('#res_body').removeClass().addClass("hljs").html("<h2 style='color:red'>连接超时,请检查网络和地址是否可用</h2>");
}).on('complete', function(data,response) {
    var headers = response.headers;
fork icon0
star icon3
watch icon2

+ 64 other calls in file

31
32
33
34
35
36
37
38
39
40
  headers: {
    'Content-Type': 'application/json'
  },
  parser: rest.parsers.json
};
rest.request(base+url, options).on('success', function(data) {
  // console.log("In handle_request.success: " + url);
  handle_success(data, callback, error);
}).on('fail', function(data) {
  // console.log("In handle_request.fail: " + url);
fork icon0
star icon0
watch icon2