-
Notifications
You must be signed in to change notification settings - Fork 36
/
http_methods.js
50 lines (41 loc) · 1.49 KB
/
http_methods.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
exports.http_methods = function(config){
var operations = require([__dirname, "operations"].join("/")).operations(config);
return {
get: function(uri, qs, fn){
operations.request(uri, qs, null, "GET", function(err, response){
if(response && response.error){
err = new Error(response.error);
response = null;
}
return fn(err, response);
});
},
put: function(uri, qs, data, fn){
operations.request(uri, qs, data, "PUT", function(err, response){
if(response && response.error){
err = new Error(response.error);
response = null;
}
return fn(err, response);
});
},
post: function(uri, qs, data, fn){
operations.request(uri, qs, data, "POST", function(err, response){
if(response && response.error){
err = new Error(response.error);
response = null;
}
return fn(err, response);
});
},
del: function(uri, fn){
operations.request(uri, null, null, "DELETE", function(err, response){
if(response && response.error){
err = new Error(response.error);
response = null;
}
return fn(err, response);
});
}
}
}