I'm developping the angular frontend of an existing API and I'm using angular-material-extensions/select-country to implement the country selection dropdown. The implementation was done and client was satisfied with how good the @angular-material-extensions/select-country looks. But I'm facing a problem when connecting the country selection to the API. For in the api, countries are designed a different way, following this interface pattern:
country interface {
"code": number,
"message": String,
"result": [
{
"name": String,
"refDatas": [
{
"code": number,
"name": String,
"translated_To_French": String
"translated_To_German": String
"translated_To_Spanish": String
"translated_To_Portuguese": String
}
]
}
]
}
But the @angular-material-extensions/select-country library's interface is like this:
country interface {
name: string;
alpha2Code: string;
alpha3Code: string;
numericCode: string;
callingCode: string;
}
Obviously the library needs this 5 properties to function and I just don't know how to match it to the API payload? As you can see in both sides we have "name", so name property causes no problem, but for the alpha2Code, alpha3Code, numericCode and callingCode I don't know the role that they play in the library. The only solution was to assign "code" to "numericCode", but it caused the app to break and I can't change the API design about countries either. Any help to bypass this impediment is much appreciated.