Call a function in NodeJS

I am trying to call a custom function using NodeJS

Created the custom function in a file ‘shortuuid.js’ in folders: extensions > server_connect > modules

I then created a function in API:
in the functions steps I created a Set Value gave it a name and called the new custom function.

I tried to see the result with a response

Tried everything but keep getting a 500 server error.

Also why is there no console.log step? It is an important part of development.

Hi Ray,

You’ll want to checkout these posts to understand how you can create your own custom modules:

Thanks I did.

If the instructions where clear I wouldn’t be asking this question.

If they are clear to you please extrapolate and answer my problem.

Ok just gone through it all again and no luck. What am I missing?

Enabled debug and got this which means the module file is not included:

server-connect:app options: { key: ‘newUID’, value: ‘{{shortuuid()}}’ } +0ms
server-connect:server Got error? ReferenceError: expression is not defined
server-connect:server at primary (/Users/raynoppe/Documents/wappler/cocktail/lib/core/parser.js:613:117)
server-connect:server at unary (/Users/raynoppe/Documents/wappler/cocktail/lib/core/parser.js:563:16)
server-connect:server at multiplicative (/Users/raynoppe/Documents/wappler/cocktail/lib/core/parser.js:541:20)
server-connect:server at addictive (/Users/raynoppe/Documents/wappler/cocktail/lib/core/parser.js:531:20)
server-connect:server at bitwiseShift (/Users/raynoppe/Documents/wappler/cocktail/lib/core/parser.js:521:20)
server-connect:server at relational (/Users/raynoppe/Documents/wappler/cocktail/lib/core/parser.js:511:20)
server-connect:server at equality (/Users/raynoppe/Documents/wappler/cocktail/lib/core/parser.js:501:20)
server-connect:server at bitwiseAnd (/Users/raynoppe/Documents/wappler/cocktail/lib/core/parser.js:491:20)
server-connect:server at bitwiseXor (/Users/raynoppe/Documents/wappler/cocktail/lib/core/parser.js:481:20)
server-connect:server at bitwiseOr (/Users/raynoppe/Documents/wappler/cocktail/lib/core/parser.js:471:20) +0ms

Did you create the .hjson file like the above post from George?

There are a couple of posts if you search custom modules in the forum.

The following post should be similar to what you want to achieve:

You are trying to create a custom module, and use it as a custom formatter.
Please read the docs again carefully.
Also, you can refer few already created custom modules for node to get a better idea.

Thanks Sid

I figured it out myself late last night. I ignored the instructions and looked through the code.

All working now.


1 Like

If you could post the final formatter code here… It might help others in future.

It’s arses like you why Wappler’s community have a bad wrap.

I can’t believe you, as an ambassador posted this against a paying client.

Shows you are either a nobody or an incredibly inexperienced business person.

@Ray please keep the discussion civilized. Personal insults like these are not really welcome here.

I will push it in to the git repository I created.

I am building a complete boilerplate that has most functionality needed by my team to get up and running fast.

User registration with pin via email verification.
Login with password recovery via pin method.

CRUD example with client side image crop, resize and upload. (Includes the modal to convert from base 64 to file on the server)

Live data tables updated with sockets.

Push notifications via One Signal.

Repository is here will push tomorrow.


Sorry but his insult was ok?

It is clear from your previous posts and replies to people trying to help you that you came to this community to fix whatever you think it’s bad about it.

That was elitist. What about non-paying users? Do they deserve to be bullied by a nobody like me?

That is actually accurate. Saves me from having to BS people into thinking I am some sort of guru.