Here is the JSON object I have:
Object { JP: "JAPAN", PAK: "PAKISTAN", IND: "INDIA", AUS: "AUSTRALIA" }
This JSON data was retrieved as a response from an HTTP GET request using HttpClient in Angular.
Now, I want to populate this data into the following structure to display it as a dropdown list.
countryList: { countryCode: string; countryName :string }[];
I attempted the following code snippet :
for (const key in resData) {
if (resData.hasOwnProperty(key)) {
var obj ={
countryCode :key,
countryName : resData[key]
}
this.countryList.push(obj);
}
}
However, upon execution, I'm encountering this error
"_this.countryList.push is not a function"
What could be the issue here?