Good morning everyone. I am facing a great difficulty. I started a week of studies on nodeJS, so I'm pretty noob.
I have a code that returns an object in json format for me and I would like to create a page that Body would receive this. however, I can not create it at all.
I'm using EJS ... I did so to receive my route.
app.get("/", function(req, res){
res.render("secao/home");
});
app.listen(3000, function(){
console.log("Servidor rodando");
});
So I would like to get the array here from home.
var http = require("http");
var options = {
"method": "GET",
"hostname": [
"{{accountName}}",
"{{environment}}",
"com",
"br"
],
"path": [
"api",
"catalog_system",
"pvt",
"category",
"tree",
"{{categoryLevels}}",
""
],
"headers": {
"content-type": "application/json",
"x-vttt-api-appkey-api-appkey": "{{X-Vtt-API-AppKey}}",
"x-vttt-api-apptoken": "{{X-Vtt-API-AppToken}}"
}
};
var req = http.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function () {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
});
req.end();
How to proceed galley. Sorry for my ignorance!