From 82fc736c4bfb86372fce9cede43bd22b9f4f0338 Mon Sep 17 00:00:00 2001 From: Geo Miller Date: Wed, 25 Jun 2014 12:30:04 -0400 Subject: [PATCH] protects the server from crashing when text is undefined, due to substr call --- routes/api.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/routes/api.js b/routes/api.js index 48deee3b..fff94582 100644 --- a/routes/api.js +++ b/routes/api.js @@ -22,6 +22,9 @@ var data = { exports.posts = function (req, res) { var posts = []; data.posts.forEach(function (post, i) { + if (typeof post.text == "undefined") { + post.text = "" + } posts.push({ id: i, title: post.title, @@ -75,4 +78,4 @@ exports.deletePost = function (req, res) { } else { res.json(false); } -}; \ No newline at end of file +};