Skip to content
This repository has been archived by the owner on Jan 9, 2018. It is now read-only.

Error exporting object data #9

Open
CoinCoderBuffalo opened this issue May 28, 2013 · 1 comment
Open

Error exporting object data #9

CoinCoderBuffalo opened this issue May 28, 2013 · 1 comment

Comments

@CoinCoderBuffalo
Copy link

Getting a strange output in the Excel CSV file:

[object Object]|"false"||"0"|"[object Object]"|"[object Object]"|"[object Object]"|"function () {
var self = this
, hookArgs // arguments eventually passed to the hook - are mutable
, lastArg = arguments[arguments.length-1]
, pres = this._pres[name]
, posts = this.posts[name]
, total = pres.length
, current = -1
, asyncsLeft = proto[name].numAsyncPres
, next = function () {
if (arguments[0] instanceof Error) {
return handleError(arguments[0]);
}
var args = Array.prototype.slice.call(arguments)
, currPre
, preArgs;
if (args.length && !(arguments[0] == null && typeof lastArg === 'function'))
hookArgs = args;
if (++current < total) {
currPre = pres[current]
if (currPre.isAsync && currPre.length < 2)
throw new Error(""Your pre must have next and done arguments -- e.g., function (next, done, ...)"");
if (currPre.length < 1)
throw new Error(""Your pre must have a next argument -- e.g., function (next, ...)"");
preArgs = (currPre.isAsync
? [once(next), once(asyncsDone)]
: [once(next)]).concat(hookArgs);
return currPre.apply(self, preArgs);
} else if (!proto[name].numAsyncPres) {
return done.apply(self, hookArgs);
}
}
, done = function () {
var args
= Array.prototype.slice.call(arguments)
, ret, total
, current
, next
, done
, postArgs;
if (current === total) {
ret = fn.apply(self, args
);
total
= posts.length;
current
= -1;
next
= function () {
if (arguments[0] instanceof Error) {
return handleError(arguments[0]);
}
var args
= Array.prototype.slice.call(arguments, 1)
, currPost
, postArgs;
if (args
.length) hookArgs = args
;
if (++current
< total
) {
currPost = posts[current
]
if (currPost.length < 1)
throw new Error(""Your post must have a next argument -- e.g., function (next, ...)"");
postArgs = [once(next
)].concat(hookArgs);
return currPost.apply(self, postArgs);
}
};
if (total
) return next
();
return ret;
}
};
if (_asyncsLeft) {
function _asyncsDone (err) {
if (err && err instanceof Error) {
return handleError(err);
}
--_asyncsLeft || _done.apply(self, hookArgs);
}
}
function handleError (err) {
if ('function' == typeof lastArg)
return lastArg(err);
if (errorCb) return errorCb.call(self, err);
throw err;
}
return _next.apply(this, arguments);
}"|"[object Object]"

@CoinCoderBuffalo
Copy link
Author

I did a workaround by first converting the data to JSON and then converting it back to Object.

Added one line to the code, and made sure to send it JSON data. I think the original issue was a bunch of "meta" properties were set that obj.hasOwnProperty(prop) was not filtering out.

res.csv = function(obj, headers, status) {
obj = JSON.parse(obj);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant