Have a problem with JSON

Hello guys! I’m new in JS, have a problem with my code:


function tbotping () {
  var MikroNode = require('mikronode');

  var device = new MikroNode('IP');

    .then(function(conn) {
  var ping = conn.openChannel();
  console.log('Get ping');

  .subscribe(function (data) {
  var myJSON = JSON.stringify(data);


code work correctly, but i can’t understand, how can i get data from myJSON to some variable, for return from main function to use. Now a can only see json data in console. Plz help! Thx alot!

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

What’s type of data?
If it is a string of JSON, you can parse the data. for example:

const myJSON = JSON.parse(data);

If not, explain more.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.