- Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathsimple.js
More file actions
Latest commit
23 lines (20 loc) · 608 Bytes
/
Copy pathsimple.js
File metadata and controls
23 lines (20 loc) · 608 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
varInterfake=require('..');
varrequest=require('request');// Let's use request for this example
varinterfake=newInterfake({debug: true});
interfake.createRoute({
request: {
url: '/whats-next',
method: 'get'
},
response: {
code: 200,
body: {
next:'more stuff'
}
}
});
interfake.listen(3030);// The server will listen on port 3030
request('http://localhost:3030/whats-next',function(error,response,body){
console.log(response.statusCode);// prints 200
console.log(body);// prints { "next" : "more stuff" }
});