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

Callback function only uses one argument #13

Open
jontxu opened this issue May 22, 2013 · 1 comment
Open

Callback function only uses one argument #13

jontxu opened this issue May 22, 2013 · 1 comment

Comments

@jontxu
Copy link

jontxu commented May 22, 2013

So using the example given (from readme file of repository and npm page), where err is an error and data is an array of arrays:

parseXlsx(xlsx, function (err, data) {
    console.log("Parsing file " + xlsx);
    if (err) throw err;
    var row1 = data[0];
    var row2 = data[1];
    console.log(row1);
    console.log(row2);
    console.log("Success!");
});

It's actually err what's an array of arrays. I mean, data is undefined. Trying the same code above, I get this on console:

/home/jon/Code/AppGenerator/node_modules/excel/node_modules/node-promise/promise.js:199
          throw error;
                ^
ID,Title,Name,Start date,End date,Lecturer,Excerpt,Location,text,prueba,nombre,41286,41317,lec,exc,micasa

Edit: After watching the code I see that the callback actually returns the variable with the actual data.

@clickclickonsal
Copy link
Collaborator

The example assumes you're inside a promise or try catch block. The issue is that you are trying to throw an error inside of a callback. Try console.log(err) instead of throwing it

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