node-moodle-client icon indicating copy to clipboard operation
node-moodle-client copied to clipboard

client.call is not a function

Open UCN0 opened this issue 5 years ago • 5 comments

I am trying to use the node client with react js and I am getting this error from this line

return client.call({
          wsfunction: "moodle_service_app",
  
     })

It says client.call is not a function. How to fix it? Thanks

UCN0 avatar Apr 10 '20 17:04 UCN0

How do you get the client ?

mudrd8mz avatar Apr 14 '20 07:04 mudrd8mz

Actually it was a mistake I was calling the client directly. But I would like to know how do I have custom web services as array. Like; Service: ["service1", "sercive2"......]. I want to be able to call a function later from my loaded services on the client, but not only one service. Does client.call( ) call a service? If I don't provide any custom service I receive this error: Unable to initialize the client: Error: authentication failed: Web service is not available. (It doesn't exist or might be disabled.). I would like to provide more than one service. thanks

UCN0 avatar Apr 20 '20 16:04 UCN0

That's not supported and not usually needed, too. What is your use case? In a typical scenario, the server is configured to expose all the required functions to perform the given task via a client in a single service.

Are you sure you are not interchanging external functions with external services? Why do you need multiple services?

mudrd8mz avatar Apr 20 '20 19:04 mudrd8mz

I organized the functions in services as a json where I can call in an organized way, for example; message_service contains only functions related to messages. course_service contains course related functions.

UCN0 avatar Apr 20 '20 21:04 UCN0

Aha. Well, if you insist in such a setup, you will need to instantiate multiple clients, too - one for messaging, one for course etc.

But again, I would not encourage for such server-side setup. I think it only overcomplicates things, require the same setup (such as authorised users, IP restrictions etc) be performed multiple times etc.

Also the tokens are generated by Moodle to use particular individual services etc.

mudrd8mz avatar Apr 21 '20 09:04 mudrd8mz