I have the following JSON object:
Object { JP: "JAPAN", PAK: "PAKISTAN", IND: "INDIA", AUS: "AUSTRALIA" }
This JSON is a response data returned from a get call(HttpClient Angular).
So now, I need to populate this into the following to display as a dropdown list.
countryList: { countryCode: string; countryName :string }[];
I tried doing the following :
for (const key in resData) {
if (resData.hasOwnProperty(key)) {
var obj ={
countryCode :key,
countryName : resData[key]
}
this.countryList.push(obj);
}
}
But when I execute I'm getting this error
"_this.countryList.push is not a function"
What am I doing wrong?