-
Notifications
You must be signed in to change notification settings - Fork 4
api.method is not a function #2
Comments
Oh, could you give me a snippet of your code? I'll try to enhance the readme a little bit, but your code should follow a structure like this (JavaScript): const ZabbixClient = require('zabbix-client').ZabbixClient;
const client = new ZabbixClient('http://zabbix-url/api_jsonrpc.php');
client.login('username', 'password')
.then((api) => {
api.method('host.get')
.call({})
.then((allHosts) => {
console.log(allHosts);
})
.catch((e) => {
console.log(e.message);
});
})
.catch((e) => {
console.log(e.message);
}); This example uses Promises, it's not really suited for production but should get you an idea. If you are not familiarized with javascript yet, it would be good to learn a bit of it before diving into typescript. |
Hi Aluisio, Using your snippet ( I am sure its successfully executable) returns
Obviously I am struggling with the project setup and node. So I have to educate myself with more basic exercises concerning this. Ralf |
Hi Aluisio, |
I'm terribly sorry, I couldn't test so I wrote the example out of my mind. I forgot to include the I've updated the example and tested it on my machine.
Great idea! I'll do it when I got some time. |
Hi Aluisio, In an example, you should also provide how to pass params for the methods. I'll stay tuned. |
Hi,
first of all, I am an absolute beginner to typescript. Allthough excercising a lot of tutorials, this is my first attempt using a foreign module/project.
I stucked, getting:
no tsc errors, trying to execute via node (node apiinfo.js). Using your example code from the Readme.md
Please could you assist. While an experienced zabbix admin I struggle with typescript, in which I identified a lot of potentials.
Regards
Ralf
The text was updated successfully, but these errors were encountered: