Skip to content

Commit 9e0ba4f

Browse files
committed
improve server.js
1 parent b3b1c78 commit 9e0ba4f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Diff for: server.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,17 @@ app.get('/v1/store/:id', function(req, res){
3838
app.post('/v1/store/:id', function(req, res){
3939
fs.writeFile(
4040
storeDir + req.params.id + '.json',
41-
JSON.stringify(req.body, undefined, 2)
41+
JSON.stringify(req.body, undefined, 2),
42+
function(){
43+
res.status(204).end();
44+
}
4245
);
43-
res.status(204).end();
4446
});
4547

4648
app.delete('/v1/store/:id', function(req, res){
47-
fs.unlinkSync(storeDir + req.params.id + '.json');
48-
res.status(204).end();
49+
fs.unlink(storeDir + req.params.id + '.json', function(){
50+
res.status(204).end();
51+
});
4952
});
5053

5154
var server = app.listen(3000, function() {

0 commit comments

Comments
 (0)