I have this code which gets values from JSON, parsed into texts, and would like to return text to my chatbot.
rooms: function(){
var board, text = "Here are the lists of boards, followed by the slug:\n\n";
Request('https://[redacted]/api/1.0/boards/', function (error, response, body) {
board = JSON.parse(JSON.minify(body));
for(var i=0; i<board.length; i++){
text += board[i].title + ": `" + board[i].slug + "`\n";
}
text += "\n Shows the list of topics in specific board with `!fbot view [slug]`";
});
console.log(text);
return text;
}
However, all the text logged and returned is Here are the lists of the boards, followed by the slug
, and does not include the parsed JSON.
If JSON parsing gets an error, NPM should be stop, however, it doesn't.
I'm new to NodeJS. Is this about something called async that makes commands not execute in sequential order?
The Request()
function used is obtained from https://github.com/request/request.
via srakrn
No comments:
Post a Comment