Cordova app not showing the same content as on localhost website

Viewed 131

While creating a cordova app - all of the requested content is displayed when using 'phonegap serve' to host it on a localhost webpage.

However, when running it on my android with 'cordova run android' - it doesn't show the same data.

I've narrowed the issue down to the app not recognizing a specific part of my code when running it on my phone, while recognizing it when hosted on a localhost webpage.

The part of the code that is causing the issue (ONLY ON MY PHONE):

 ${_priWaardes[i].children.map(child => "<li>" + child + "<li>")}

This code shows perfectly fine on my localhost webpage - but when running on android and checking the console log, this specific error shows:

Uncaught TypeError: Cannot read property 'map' of undefined

If I delete this part of the code - the app works fine on android, showing everything (except the children of the array ofcourse.)

Is there another way to list the children of an array on my phone ? Or is this a specific cordova bug that can be resolved ?

1 Answers

This is because arrow functions are not supported by WebViews (yet). You need to polyfill if you want to use these methods, or a transpiler like Babel.

Related