I can't get the custom JS results out, always get error!

Hello,

I’m trying to get Sun calculations, I use custom JS for that, I think I put inputs and outputs, etc. correctly but I can’t get it done, I tried many variations of the code and always get the catch error message.

my app url: https://platform.appgyver.com/builder/applications/190371/pages/1

I use the calculations from: GitHub - mourner/suncalc: A tiny JavaScript library for calculating sun/moon positions and phases.

the screenshot I took the part of calling the function:

Could you please check what I am doing wrong, I try many other ways so the app page seems a mess, sorry about that, the particular calculation I am talking about is bound to the Card1 tap,

thank you.

One thing to note is that the GPS started not to work, even the phone location is on, the app doesn’t get the location.

Hi, sorry for the delayed response. Did you manage to get the custom JS to work?

Thank you @Mari for the reply, I simplified the app-in elements to clear and see better, I want the JS code to work, it is the main idea, it is ready, I think I’m doing wrong in how to call the functions, could you help me run successfully, I tried to do it in many ways, just couldn’t get it,

the app number is up in the previous message, the app URL,

Thank you very much.

I’m also interested in your solution, since I receive the same error when attempting to use custom JS.

Hey @yasin_sahin, I’m curious as to how are you loading the library code into the JS custom function?

Hey @Juan_Giraldo, I use the plain JS code from the suncalc codes (I gave the GitHub link above), supposedly the functions are there and ready to be called, I try to call with different combinations, but can’t get it right, I tried with different data types, variable varieties, etc. as well, no luck so far,

I’m still not sure what you mean. Looking at the library in GitHub, did you just paste the contents of the suncalc.js file into your custom JS flow function?

yes, of course, no change, just the code itself, trying to call, well maybe I’ll do some changes, but I want to run it successfully first,

Hi @yasin_sahin, sorry I overlooked what you were actually trying to do here – unfortunately it’s not yet possible to use custom libraries in the JS node, but custom plugins are on the development roadmap. :slight_smile:

Hey @Mari, any latest update on custom plugins? Will it be released this year?

Hi @Mari, the JS code has a bunch of calculations, is there any custom library in the code, I didn’t get fully what you said, you mean “Custom JS” doesn’t run with the code, did you check my app, the code is in the upper button, could you please specify because of what code it wouldn’t run,

thank you.

@yasin_sahin “Custom JS” means that you can write your own JS code to be run in the app, but you cannot include any external dependencies that are not otherwise included, such as the SunCalc library. The app won’t know how to execute this code. However, as the SunCalc itself doesn’t have any dependencies (it’s just math), you could copy the functions you need into the JS box and use them that way. :slight_smile:

@Juan_Giraldo See Harri’s answer in the tracker: Custom React Native / React web plugins | Voters | AppGyver

1 Like

@Mari :slight_smile: yes, exactly what I am trying to explain, did exactly that, my function call doesn’t work out and/or return the values out, I’d need someone to help me on that, thank you, :slight_smile: :relaxed:

Hi, sorry for the misunderstanding :grinning_face_with_smiling_eyes: We unfortunately don’t have the resources for debugging help, but I suggest you just add the required code piece by piece and just test after each function that it actually works. If you open the Google Chrome debug console (right-click + “Inspect”), you’ll see the error messages that you are getting when running your code, you can also use console.log type debugging into the Chrome console from within your code.

Here’s a quick example of how the inputs / outputs work. If I set input1 to True, I will trigger the first alert, and the 2nd if I set it to False. Pay attention that the output object names match those that you have in your code. :slight_smile:

image