function handleApiRequest(event) {
            var data = event.data;
            require(["./sandbox/" + data.module], function(mod) {
                if (!mod[data.call]) {
                    return event.source.postMessage({
                        replyTo: data.id,
                        err: "No such method: " + mod
                    }, "*");
                }
                var r = mod[data.call].apply(mod, data.args);
                if (!r || !r.then) {
                    console.error("Got empty result from", mod, data.call);
                }
                r.then(function(result) {
                    event.source.postMessage({
                        replyTo: data.id,
                        result: result
                    }, "*");
                }, function(err) {
                    event.source.postMessage({
                        replyTo: data.id,
                        err: err,
                    }, "*");
                });
            });
        }
Handle a request coming from within the sandbox, and send back a response