0

I can't seem to get the individual values from my returned list - how do I do this please? What do I replace the ? for each field? The results returned will always only be these 2 fields. The Apex call returns a list of strings as shown in the alert.

.then(result => {
    alert('results: ' + result); // this returns the following:    results: abc,def
    this.field1 = ?;   //I want abc in here
    this.field2 = ??;  //and def in here
}

2 Answers 2

0

After some more playing around it seems it's as simple as

this.field1 = results[0];
this.field2 = results[1];
0

You can use destructuring assignments assign multiple values from an array:

.then(result => [this.field1, this.field2] = result);

You must log in to answer this question.

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