Page 1 of 1

Ionic 4 - returning data from a function

Posted: Mon May 18, 2020 4:30 pm
by Andy Parker

Hi all,

apologies if this is a daft question, but I am re-writing a major app from Ionic1 to Ionic4 and have a challenge.

I need to return data from several functions, but I get the msg:
"A return statement can only be used in a function body"

The function I have created, is as follows:
Name: getTeamNameFromID(id) (type:method)
the code simply loops around an array until it finds the id passed by the caller, then returns the name in the array at that point.

Can anyone tell me how I return the string please?


Ionic 4 - returning data from a function

Posted: Tue May 19, 2020 1:24 pm
by Serhii Kulibaba

Hello Andy,

You can ignore this message, it works fine if you return a string right in that function