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

Potential issue returning array or object #25

Open
paralin opened this issue Apr 17, 2015 · 1 comment
Open

Potential issue returning array or object #25

paralin opened this issue Apr 17, 2015 · 1 comment

Comments

@paralin
Copy link

paralin commented Apr 17, 2015

You return an array for response if the response parts count is greater than one, and an object if there is a single response.

What if the response is for something like channellist and there is a single channel? The code won't know to expect an object or an array because the response could be a single or multiple number of channels.

@zyberspace
Copy link
Contributor

Had this problem too, solved it in my teamspeak-wachhund like this:

if (!response) {
    response = [];
} else if (!Array.isArray(response)) {
    response = [response];
}

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

No branches or pull requests

2 participants