Having trouble displaying axios data properly in nodeJS, puts data in one tag instead of giving each its own element
So I'm practicing Node JS after taking a udemy course I'm using Pug as a template engine. In the video we made cards and each had its own card for each piece of data passed. My code looks close to the videos (sense I'm not doing the same exact thing) but it puts all the data from my axios request into one element instead of giving the data its own element. If anyone can point me in the right direction I'd love it thanks.
Controller file
exports.getAllSymbols = async (req, res, next) => {
let data = [];
const x = await axios.get(options.allStocksURL, options.allStockOptions);
const stocks = await x.data.data[0];
const stock = x.data.data[0].name;
const symbol = stocks.symbol.toString();
for (let y = 0; y <= x.data.data.length - 1; y++) {
data.push(x.data.data[y].symbol);
}
res.status(200).render("base", {
StockName: stock,
StockSym: data,
});
};
Pug File
html
head
meta(charset='UTF-8')
meta(name='viewport', content='width=device-width', initial-scale='1.0')
link(rel='stylesheet', href='/css/style.css')
link(rel='shortcut icon', type='image/png', href='/img/favicon.png')
link(rel='stylesheet', href='https://fonts.googleapis.com/css?family=Lato:300,300i,700')
title Dashboard | #{title}
body
// header
include _header
//- CONTENT
block content
div
h3 #{StockName}
h3 (#{StockSym})
Via Active questions tagged javascript - Stack Overflow https://ift.tt/JXOw2a6
Comments
Post a Comment