How to call function from server.js into app.js?

1.) I’m trying to call a function from server.js into app.js but I think I’m unable to do so maybe because of a syntax error.
2.) Im keep getting the below error:
{message: “Requested function ‘fetchContacts’ not found or registered”, status: 404, errorSource: ‘APP’}

3.) server.js ::
async function fetchContacts(args) {
const response = await axios.get(args.url, args.options)
return response
exports = { fetchContacts,}

4.)app.js ::
const url=“abcd”
const options="{xyz:abc}"
const contactData = await client.request.invoke(‘fetchContacts’, {url,options})

5.) could someone explain me how to do that?

Hi @Asim_Shah, have you registered the function in manifest.json? (See: Register the SMI function section)


Thanks @kaustavdm
Brother one query more :
Q) Can I create a server app using ExpressJs etc in server.js, assume I wanted to create a CRUD app? is it possible? (though i think its an static web app creation)

You cannot. server.js exposes specific interfaces that map to our app platform infrastructure. You will not be able to bind the port of an HTTP server, and you cannot receive requests.

But, if you need a place to store objects and interact with them in a CRUD-like way, consider using Entity Storage.


This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.