7 months ago

Filtering through array for specific name

Posted 7 months ago by chrisgrim

Hi, two questions here. First is if I am doing this a stupid over complicated way and second, why is the way I am trying not working?

I have a selector dropdown that allows a user to choose a country. In my vue this country is saved to data as an object. I then get the from the object and save that to the database. This works great. The issue I am having is I want to repopulate the data if the user goes back to the form except now I no longer have an object, only the country name as a string.

My idea is that I should filter through the countries array searching for the name. Is that the smartest way of doing this? My second question (if this is the right way to do this) is what am I doing wrong with my code?

in my data for simplicity sake I have

keyword: 'Afghanistan',
countrydata: [],

when the page loads my country data looks like this

name:"Ă…land Islands"

and so on

The country data is loaded using a mounted method that pulls it from Finally I have my computed property which isn't working

computed: {
            countryFilteredList() {
                return => {
                    return this.keyword.toLowerCase().split(' ').every(v => country.title.toLowerCase().includes(v));


Please sign in or create an account to participate in this conversation.