for some reason when I output to a textbox it writes [Object object]
here is my code below although it is a array.
This is not a duplicate question because in console.log it shows an array of all the scraped data but when putting that data into a text box it just shows [Object object]
const request = require('request');
const cheerio = require('cheerio');
var options = {
headers: {
'user-agent': 'request'
}
};
function somefunction() {
request('https://kith.com/collections/footwear/products/jbaq4160-140', options, (error, response, html) => {
if (!error && response.statusCode == 200) {
const $ = cheerio.load(html);
var output = $('form[action="/cart/add"] select#productSelect > option').map((i, elem) => ({
size: $(elem).text(),
val: $(elem).attr('value')
})).get().reduce((acc, cur, i, arr) => {
arr.obj = arr.obj || {};
arr.obj[cur.size] = cur.val;
return arr.obj
}, {});
document.querySelector('#out').innerHTML = output;
console.log(output);
console.log('done');
}
});
}
In texbox it just outputs [Object object] no idea what to do from here.