Skip to content

Commit 95cdfc6

Browse files
committed
[Kong#11][feature] Finished request samples in test
1 parent f601ecc commit 95cdfc6

2 files changed

Lines changed: 18 additions & 42 deletions

File tree

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
1-
var http = require("http");
1+
var request = require('request');
22

33
var options = {
4-
"method": "GET",
5-
"hostname": "mockbin.com",
6-
"port": null,
7-
"path": "/har?key=value&baz=abc&foo=bar&foo=baz",
8-
"headers": {}
9-
};
10-
11-
var req = http.request(options, function (res) {
12-
var chunks = [];
13-
14-
res.on("data", function (chunk) {
15-
chunks.push(chunk);
16-
});
17-
18-
res.on("end", function () {
19-
var body = Buffer.concat(chunks);
20-
});
4+
url: 'http://mockbin.com/har?key=value&baz=abc&foo=bar&foo=baz',
5+
headers: {}
6+
}
7+
request.get(options, function(error, response, body) {
8+
if (error){
9+
//throw error here
10+
return;
11+
}
12+
// work with response and body here;
2113
});
22-
23-
req.end();
Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,9 @@
1-
var http = require("http");
2-
3-
var options = {
4-
"method": "GET",
5-
"hostname": "mockbin.com",
6-
"port": null,
7-
"path": "/har?",
8-
"headers": {}
9-
};
10-
11-
var req = http.request(options, function (res) {
12-
var chunks = [];
13-
14-
res.on("data", function (chunk) {
15-
chunks.push(chunk);
16-
});
17-
18-
res.on("end", function () {
19-
var body = Buffer.concat(chunks);
20-
});
1+
var request = require('request');
2+
3+
request.get('http://mockbin.com/har?', function(error, response, body) {
4+
if (error){
5+
//throw error here
6+
return;
7+
}
8+
// work with response and body here;
219
});
22-
23-
req.end();

0 commit comments

Comments
 (0)