[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

Problems saving JSON. Getting [[Object]]

dieguezz

8/16/2014 4:18:00 PM

Hi, i am trying to save a json with "somewhere".

This function is incomplete but its enough to show the problem:



function testJSON(products) {
var productsPromises = products.map(function(product) {
var title = product['Title'];
var stock = product['Stock'];
var price = product['Price'];
if (stock == "Disponible") {
stock = true;
} else {
stock = false;
}
var toPush = [{Stock: stock, Price: price}];
var results = {Title: title, Results: toPush};
db.connect('./bricogeek/results.json');
var find = db.find('Productos', {Title: title});
console.log(find);


});
return Promise.all(productsPromises);
}

That returns:

[ { Title: 'Grabador de voz ISD1932',
Results: [ [Object] ],
id: 'f4099bff-fc55-4697-b712-d84343931818' } ]
[ { Title: 'Arduino SD Card Shield',
Results: [ [Object] ],
id: '75c79411-a905-41b3-9578-bb7072139a4d' } ]
[ { Title: 'Placa prototipo con zócalo para microSD Transflash',
Results: [ [Object] ],
id: 'af21962a-197e-43db-aba2-779be95357f2' } ]
[ { Title: 'Frontal para LCD 32PTU (Negro)',
Results: [ [Object] ],
id: '29d1e6cd-b549-44ad-87af-e4a4a056a609' } ]


I saved it same way but using db.save('Productos', results); instead of db.find(...

Why am i getting [[Object]] instead of the data? How can i fix this?