So I'm exporting a callback-function in a module like this:
(function() {
    let request = require("request");
    module.exports = function GithubApi(url, callback) {
        let options = {
            uri: url,
            headers: {
                "User-Agent": "Me",
                "Content-Type": "application/x-www-form-urlencoded"
            }
        };
        request(options, function(err, body) {
            let context = {
                issues: JSON.parse(body.body).map(function(issue) {
                    return {
                        title: issue.title,
                        comments: issue.comments,
                    };
                })
            };
            callback(context) // The callback
        });
    };
}());
And this callback works perfectly fine when I'm using it in my GET-request with express.js:
app.get("/", (req, res) => {
    let url = "some url";
    GithubApi(url, (data) => {
        res.render("../some-views", data);
    });
});
But when I add a socket-emit, the callback-function returns SyntaxError: Unexpected end of JSON input
app.get("/", (req, res) => {
    let url = "some url";
    GithubApi(url, (data) => {
        io.socket.emit("update", {message: data}); // adding this
        res.render("../some-views", data);
    });
});
Can't understand why the socket would interfere with the request and return an error with JSON. Can anybody help?
 
     
    