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

ReferenceError: btoa is not defined #11

Open
raulrpearson opened this issue Aug 30, 2020 · 4 comments
Open

ReferenceError: btoa is not defined #11

raulrpearson opened this issue Aug 30, 2020 · 4 comments

Comments

@raulrpearson
Copy link

I'm using xmlrpc.client in Node.js and I found out that I was sometimes calling it with bad arguments which triggered this default case I assume, which threw ReferenceError: btoa is not defined.

As far as I'm aware, btoa is not available in Node.js and maybe this would require an alternative solution.

@scripting
Copy link
Owner

First, thanks for the report, glad to have a chance to fix this.

I'm looking at the code, and it seems to me that there's code at the top of the switch statement that provides a good answer.

If I make the change are you in a position to test that it works. That is, can you call it again with the "bad arguments"?

@raulrpearson
Copy link
Author

Yes, let me know how I can help.

I'm using your library to make calls to the Odoo API and I believe the call that is creating the problem goes something like this:

xmlrpc.client(
  "url",
  "execute_kw",
  [
    "db_string",
    parseInt("uid_string"),
    "pass_string",
    "odoo_model",
    "search_read",
    [[[ "id", "=", undefined ]]],
  ],
  "xml",
  callback
);

If I check my args before I make the call–specifically, if I don't pass an undefined–I stop getting the problem. Which I assume is just that the default case is never being reached.

@scripting
Copy link
Owner

scripting commented Aug 30, 2020

I fixed getXmlValue -- it should now correctly generate the <base64> encoding in the default case.

The new version is 0.4.26.

@raulrpearson
Copy link
Author

Thanks, Dave. I updated and triggered the same conditions and got TypeError: Cannot read property 'toString' of undefined. Which, when looking at the code, makes sense. I shouldn't be passing in an undefined in the first place.

How does one xmlize undefined or null? Is there a convention for that in XML?

An alternative might be to throw a descriptive error when encountering those values.

Anyway, thanks for checking this out so quickly.

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