1.2.0 • Published 2 years ago

isobarot-client v1.2.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

isobarot-client

  • Client library for sending data to isobarot cloud over HTTP or MQTT.

Getting Started

npm install --save isobarot-client

HttpClient Example

const { HttpClient } = require("isobarot-client");
const httpClient = new HttpClient(`app.isobarot.com`);

httpClient.send({
  apiToken: "<api-token-here>",
  createdAt: "2022-03-31T12:22:12.000Z",
  record: {
    // properties here
  }
})
.then(response => console.log(response.data))
.catch(error => console.log(error.response.data));

MqttClient Example

const { MqttClient } = require("isobarot-client");
const mqttClient = new MqttClient(`app.isobarot.com`);

mqttClient.init()
// Connection to the MQTT Broker success
.then(() => {
  // Send the data
  mqttClient.send({
    apiToken: "<api-token-here>",
    createdAt: "2022-03-31T12:22:12.000Z",
    record: {
      // properties here
    }
  });
  // Send the data with QoS and Retain options
  mqttClient.send({
    apiToken: "<api-token-here>",
    createdAt: "2022-03-31T12:22:12.000Z",
    record: {
      // properties here
    }
  }, {
    qos: 2,
    retain: true
  });
  // Subscribe to topic
  mqttClient.subscribe('some/topic', data => {
    console.log(data);
  });
})
// Connection to the MQTT Broker failed
.catch(error => {
  console.log(error);
  // Close connection
  mqttClient.close();
});
1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago