How to read txt file from the Internet and write its contents to a variable on node.js
const http = require('http'); http.get('http://hexando.me/projects/fc/status.txt', (res) => { let data = String(); res.on('data', (chunk) => { data += chunk; }); }); fc.on('message', (message) => { if(message.content == "fc status") { message.reply(data) } });
new String()better to replace with '' - ThisManfc? and what is the difficulty? - ThisManfc.on ...2. Addres.on('end' ...to the closure, otherwise how to understand that the data is all sucked in? @See documentation - Total Pusher