GithubHelp home page GithubHelp logo

Comments (5)

aluisiora avatar aluisiora commented on August 24, 2024

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.

from zabbix-typescript-client.

loetmann avatar loetmann commented on August 24, 2024

Hi Aluisio,
thanks for your support and prompt reply. I am relativly familiar with javascript (in the browser). To be honestly. This is my first attempt writing and executing code for node.js.

Using your snippet ( I am sure its successfully executable) returns

api.method(...).then is not a function

Obviously I am struggling with the project setup and node. So I have to educate myself with more basic exercises concerning this.
Again: Thanks a lot for your support.

Ralf

from zabbix-typescript-client.

loetmann avatar loetmann commented on August 24, 2024

Hi Aluisio,
what about a complete example as a project in an example folder?
Greetings
Ralf

from zabbix-typescript-client.

aluisiora avatar aluisiora commented on August 24, 2024

I'm terribly sorry, I couldn't test so I wrote the example out of my mind. I forgot to include the call({}) method before then().
The method method() 🤔 returns a ZabbixCommunicator object, which has the call() method that returns a promise.
While method() sets the method from zabbix that you want, call() do the zabbix call with the parameters that you want.

I've updated the example and tested it on my machine.

what about a complete example as a project in an example folder?

Great idea! I'll do it when I got some time.

from zabbix-typescript-client.

loetmann avatar loetmann commented on August 24, 2024

Hi Aluisio,
this was a big step for ... me. OK, the given Javascript example is a starting for me. I tried hard to get rid of the ts-notation-

In an example, you should also provide how to pass params for the methods.

I'll stay tuned.

from zabbix-typescript-client.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.