1
Good morning, guys. I’m having a really hard time. I started a week ago studying in nodejs, so I’m well.
I have a code that returns an object in json format to me and I would like to create a page that Body would receive that. but I can’t create at all.
I am 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");
});
Then I would like the home to receive the array from here.
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 guys. Excuse my ignorance!!!