I am trying to send a variable from angular to nodejs api and I am being able to do so but my problem is with this line:
test:Array<string> = ["cool"];
public data = {1:this.test};
I am sending the request as this:
this.http.post("http://localhost:3000/api/v1/upload/",this.data).subscribe();
now in the nodes.js api i am doing this:
app.post('/api/v1/upload', upload.array('image', 1), (req, res) => {
/* This will be the response sent from the backend to the frontend */
data = req.body;
console.log(data);
res.send({ image: req.file });
});
I am getting in console.log 2 values, the first is expected "cool" but the weird one is undefined!
why I am getting the second one "undefined"?