Skip to content

Commit 76118f4

Browse files
committed
filled in endpoints for profile
1 parent 60a022f commit 76118f4

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

backend/lib/character/index.js

+16-4
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,16 @@ exports.findAll = function(req, res) {
4040

4141
exports.findById = function(req, res) {
4242
var id = req.params.id;
43-
res.json({status: 'ok', id: id});
43+
character.getProfileById(id).then(function(profile) {
44+
res.json(profile);
45+
}).catch(function() {
46+
res.status(400).json({status: 'something went wrong'});
47+
});
4448
};
4549

4650
exports.create = function(req, res) {
4751
debug('name', req.params.name);
48-
character.newCharacter(req.params.name).then(function(name) {
52+
character.newProfile(req.params.name).then(function(name) {
4953
res.json({name: name});
5054
debug('fulfilled', name);
5155
}).catch(function() {
@@ -55,10 +59,18 @@ exports.create = function(req, res) {
5559

5660
exports.update = function(req, res) {
5761
var id = req.params.id;
58-
res.json({status: 'ok', id: id});
62+
character.updateProfileById(id).then(function(profile) {
63+
res.json(profile);
64+
}).catch(function() {
65+
res.status(400).json({status: 'something went wrong'});
66+
});
5967
};
6068

6169
exports.destroy = function(req, res) {
6270
var id = req.params.id;
63-
res.json({status: 'ok', id: id});
71+
character.destroyProfile(id).then(function(profile) {
72+
res.json(profile);
73+
}).catch(function() {
74+
res.status(400).json({status: 'something went wrong'});
75+
});
6476
};

0 commit comments

Comments
 (0)