When making a post call in Angular using Http.post, I am sending jsonData as a parameter with the following formatted data. However, every time I receive a response as null. Could you please review my code and let me know if there are any mistakes? Here is a sample of the code I have tried:
let jsondataItems :any =[];
var jsonData = [
{
"empId": 11234,
"salary": "98763",
"test1id": "9897989",
"test2id": "657453",
"test3id": "4456",
"month": "AUG-19"
}]
this.http
.post<empData>(url, jsonData)
.subscribe((res) => {
this.jsondataItems = res;
console.log("res" + this.jsondataItems); // receiving null
console.log("res" + JSON.stringify(this.jsondataItems)); // receiving null
console.log("Processed successfully!!!"); // console -- working
});
}
interface empData {
empId: number; //1234
salary: string; //"3456"
test1id: string; //""5678"
test2id:string; //"5643"
test3id:string; // "4533"
month: string; //"JAN-20"
}