Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route Forwarding: receive multiple arguments res.io.respond(a,b,c,...) #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mcfog
Copy link

@mcfog mcfog commented Mar 9, 2014

I love the idea of Route Forwarding but somehow encounter a problem. I prefer pass result or error to browser with node style [err, result, ...] which is really common convention

    try {
        var data = doSomething();
        res.io.respond(null, data);
    } catch(err) {
        res.io.respond(err);
    }

but it doesnt work with Route-Forwarding because express's res.json expect additional param as status code, so res.io.respond(null, data) => res.json(null, data) just crash express.

writing sth. like res.io.respond(500, err) works with current express.io but really sounds strange, so I send this PR to change this behavior. it does break backward compatibility but I believe it worth that

…1, arg2, ...)` => `res.json([null, arg1, arg2, ...])`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant