mudrd8mz / node-moodle-client

Node.js client for Moodle web services API
Other
91 stars 19 forks source link

client.call is not a function #19

Open UCN0 opened 4 years ago

UCN0 commented 4 years ago

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

mudrd8mz commented 4 years ago

How do you get the client ?

UCN0 commented 4 years ago

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

mudrd8mz commented 4 years ago

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?

UCN0 commented 4 years ago

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.

mudrd8mz commented 4 years ago

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.