Reputation: 212
I have the following method in my class MakeRequest.js:
export default class MakeRequest{
send() {
var data = 'foo';
var data2 = 'bar';
return [data, data2];
}
}
I am trying to access data and data2 from a different class:
(array) => MakeRequest.send(JSON.stringify(query));
alert(array[0]);
The error message displayed is
Can't find variable: array
Why is 'array' not accessible?
Upvotes: 0
Views: 72
Reputation: 2599
array
is out of scope. Your lambda ends with the send
call. If you're wanting to alert within it, and not return the output of that method call, do something like this:
(array) => {
MakeRequest.send(JSON.stringify(query));
alert(array[0]);
}
Upvotes: 1