Closed panditthecoder closed 7 years ago
Thank you for submitting this issues!
I don't quite understand the following line:
alldetails[i] = new Array();
alldetails[i]["Store"] = input.priceDetails[i].store;
It might work if you change it to:
alldetails[i] = new Object();
Does that work?
if i change the line alldetails[i] = new Array (); to alldetails[i] = new Object(); the output I get is { "message": "Total Cost allDetails Array [object Object],[object Object] manual method output--- Seller = amazon cost = 23" }
The fix would be in the cb routine where you would need to use Object.keys(obj) to get an ennumeration of the keys and then loop through them to get the values.
hth
Thank you for getting back!
I think the remaining problem has to do with how JavaScript converts arrays of objects into strings.
I don't think it does. So the problem is this line:
cb(null, {message: "Total Cost"+ "<br> allDetails Array " + alldetails + "<br> manual method output" + arrayfirstrow});
And here specifically Array " + alldetails + "<br>
.
alldetails
is of the type array and JS implicitly turns this into a string. ObjectHub has no influence on this, so it's not an issue in OH.
You can fix this in the following two ways:
cb(null, {message: "Total Cost"+ "<br> allDetails Array " + JSON.stringify(alldetails) + "<br> manual method output" + arrayfirstrow});
cb(null, {
message: "Total Cost",
alldetails: alldetails
});
Does this solve your issue?
yes, you are correct. that is the way native js also handles it so this can be marked as closed.
Thank you, closing this issue now!
the cd function does not handle arrays very well. See below for example:
input for both the JS code snippets is the same { priceDetails:[{store:amazon,cost:23},{store:flipkart,cost:15}]
}
code snippet 1 (which works as expected) JS Code
Output / result { "message": "Total Cost allDetails Array amazon,23,flipkart,15 manual method output--- Seller = amazon cost = 23" }
code snippet 2 (which does not work as expected) JS Code
Output / result { "message": "Total Cost allDetails Array ,
manual method output--- Seller = amazon cost = 23"
}