From d22438abb8fdd926b75b553aa2fee408c85c7703 Mon Sep 17 00:00:00 2001 From: Austin Melms Date: Mon, 23 Jan 2017 09:56:33 -0500 Subject: [PATCH] Update app.js --- app.js | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/app.js b/app.js index 325f36d..359ce3b 100644 --- a/app.js +++ b/app.js @@ -33,21 +33,15 @@ var cio = function (user, key) { }.bind(this)); } - this.ask = function (input, callback) { - request.post({ url: base_url + "ask", form: { - user: this.user, - key: this.key, - nick: this.nick, - text: input - }}, function (err, httpResponse, body) { - if (err) throw err; - if (JSON.parse(body).status == "success") { - callback(false, JSON.parse(body).response); - } - else { - callback(true, JSON.parse(body).status); - } - }); + this.ask = function (input, callback) { + request.post({ url: base_url + "ask", form: { + user: this.user, + key: this.key, + nick: this.nick, + text: input + }}, function (err, httpResponse, body) { + callback(err, body && JSON.parse(body), httpResponse) + }); } } module.exports = cio;