-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.js
21 lines (21 loc) · 1.01 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// You may need to install bluebird first
var Promise = require("bluebird");
var rest = require("./index")(Promise);
rest.get("http://google.com/ssss").then(function (response) {
console.log(response);
}).catch(function (errorResult) {
// Note, the errorResult is an object containing an "error" property holding
// the Error object and an optional "response" property holding the the response
// object (if any). The response object will be missing, for example, if there is
// no response from server.
console.log(errorResult);
});
rest.request("https://google.com", {method: 'GET', parser: rest.restler.auto}).then(function (response) {
console.log(response);
}).catch(function (errorResult) {
// Note, the errorResult is an object containing an "error" property holding
// the Error object and an optional "response" property holding the the response
// object (if any). The response object will be missing, for example, if there is
// no response from server.
console.log(errorResult);
});