forked from RhodesPeter/request-module-workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
28 lines (23 loc) · 771 Bytes
/
app.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
"use strict";
const request = require('request');
const myRequest = () => {
/*
create your own request module here.
It should take a url to make a http GET request, and a callback function with three arguments;
1. error (String: if an error occurred),
2. response(Object; includes the response & statusCode of the request),
3. body (String; includes the body of the request)
*/
}
// Helper
const testRequest = (module) => {
module('http://jsonplaceholder.typicode.com/users/1', function (error, response, body) {
console.log('error:', error);
console.log('statusCode:', response && response.statusCode);
console.log('body:', body);
});
};
// request module test
testRequest(request);
// // myRequest module test
testRequest(myRequest);