1

Why is string.split() not working. I am getting an error message that it can't read undefined .split method. The code is

temp;
        @wire(fetchUsers)
            WiredType({ error, data }){
                for (var key in data) {
                
    //data has 1 element only.
                    this.temp = JSON.stringify(data[key].Users__c);
                }
                console.log(this.temp.split('a'));
               
            }

1 Answer 1

2

string.split is not working because it's not a string that you are trying to split - it's either undefined or null

If your users result is an array of objects, then it might be better to use a non keyed iterator. ie:

data.forEach( datum => {
  this.temp = datum.Users__c;
});

Not having the data structure it's hard to get any more precise than this.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .