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