Skip to content

Commit 6f86979

Browse files
committed
Retrieve
1 parent 2bc312e commit 6f86979

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

nodejs/class-8/mongoose-user/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ var server = http.createServer(function (req, res) {
3535
// res.end(msg);
3636
});
3737

38-
server.listen(3000, () => {
39-
console.log('Server running in localhost:3000');
38+
server.listen(8080, () => {
39+
console.log('Server running in localhost:8080');
4040
});

nodejs/class-8/mongoose-user/model.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ const CRUD = {
3232
});
3333
});
3434
}
35-
, retrieve: (query) => {
36-
User.find(query, (err, user) => {
35+
, retrieve: (req, res) => {
36+
User.find({}, (err, users) => {
3737
if (err) return console.log('Error', err);
3838

39-
return console.log('Found', user);
39+
res.writeHead(200, {'Content-Type': 'application/json'});
40+
return res.end(JSON.stringify({users: users}));
4041
});
4142
}
4243
, get: (query) => {

0 commit comments

Comments
 (0)